From 56cb783de4602549de9849685868a0bb9879b171 Mon Sep 17 00:00:00 2001 From: Narciso Jaramillo Date: Tue, 18 Sep 2012 16:56:56 -0700 Subject: [PATCH 1/2] To work around doc syncing bugs, do edits in the editor we were called from instead of the underlying document --- main.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.js b/main.js index e50f23b..0f25575 100644 --- a/main.js +++ b/main.js @@ -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. + // *** (FILE BUG) 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); } } } From 035eb42590ba7c71470374e7fa03238eb36e76c1 Mon Sep 17 00:00:00 2001 From: Narciso Jaramillo Date: Tue, 18 Sep 2012 17:00:26 -0700 Subject: [PATCH 2/2] Added bug reference --- main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.js b/main.js index 0f25575..7cfec22 100644 --- a/main.js +++ b/main.js @@ -150,7 +150,7 @@ define(function (require, exports, module) { // 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. - // *** (FILE BUG) + // See #1688. if (token.className === "string" || token.className === "number") { // replace editor._codeMirror.replaceRange(actualCompletion, {line: cursor.line, ch: token.start},