Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #20 from adobe/nj/issue-19
Browse files Browse the repository at this point in the history
Fix sync issues when accepting code hint in inline editor
  • Loading branch information
gruehle committed Sep 19, 2012
2 parents 6655f1d + 035eb42 commit 344f887
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,16 @@ define(function (require, exports, module) {
actualCompletion = stringChar + actualCompletion + stringChar;
}


// HACK: We talk to the private CodeMirror instance directly to replace the range
// instead of using the Document, as we should. The reason is due to a flaw in our
// current document synchronization architecture when inline editors are open.
// See #1688.
if (token.className === "string" || token.className === "number") { // replace
editor.document.replaceRange(actualCompletion,
editor._codeMirror.replaceRange(actualCompletion,
{line: cursor.line, ch: token.start},
{line: cursor.line, ch: token.end});
} else { // insert
editor.document.replaceRange(actualCompletion, cursor);
editor._codeMirror.replaceRange(actualCompletion, cursor);
}
}
}
Expand Down

0 comments on commit 344f887

Please sign in to comment.