Facing problem on using replaceRange.

I am using replaceRange on my case in while loop,If matched some text in regex patten and called replaceRange option. The problem is that replacerange position called again again in while loop and page hang.

That really sounds like a problem with your loop, and not something CodeMirror can help.

If i commend that line then its working fine. this is code i am running

    > let editor = this.get('editor');
    let n = editor.getDoc().lineCount();
    var obj = {};
    for (let i = 0; i < n; i++) {
        let content = editor.getDoc().getLine(i);
        if (content !== undefined && content.includes("${") && content.includes("}")) {
            let re = /\${\s*[\-\w\.]+\s*}/g;
            let match, pos, pos1;
            while ((match = re.exec(content)) != null) {
              let cls = "selectedText"; //NO I18N
              let regTxt = String(match);
              if(regTxt.includes("-"))
              {
                  let matchStr = regTxt.slice(2, regTxt.length-1);
                  let matchParams = matchStr.split("-");
                  let text = matchParams[0];
                  let label = matchParams[1];
                  obj[text] = label;
                  pos = {
                      line: i,
                      ch: match.index
                  };
                  pos1 = {
                      line: i,
                      ch: match.index + String(text).length
                  };
                  editor.replaceRange(text, pos, pos1, );
                  }
            }
     }
}