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

Commit 60dbbce

Browse files
committed
Merge pull request #3711 from adobe/nj/issue-3709
Hack yet another place where we need to use _codeMirror.replaceRange()...
2 parents 20c7491 + 91ffeb2 commit 60dbbce

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/document/DocumentManager.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,6 +814,14 @@ define(function (require, exports, module) {
814814
* given new text; if text == "", then the entire range is effectively deleted. If 'end' is omitted,
815815
* then the new text is inserted at that point and all existing text is preserved. Line endings will
816816
* be rewritten to match the document's current line-ending style.
817+
*
818+
* IMPORTANT NOTE: Because of #1688, do not use this in cases where you might be
819+
* operating on a linked document (like the main document for an inline editor)
820+
* during an outer CodeMirror operation (like a key event that's handled by the
821+
* editor itself). A common case of this is code hints in inline editors. In
822+
* such cases, use `editor._codeMirror.replaceRange()` instead. This should be
823+
* fixed when we migrate to use CodeMirror's native document-linking functionality.
824+
*
817825
* @param {!string} text Text to insert or replace the range with
818826
* @param {!{line:number, ch:number}} start Start of range, inclusive (if 'to' specified) or insertion point (if not)
819827
* @param {?{line:number, ch:number}} end End of range, exclusive; optional

src/extensions/default/JavaScriptCodeHints/main.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,11 @@ define(function (require, exports, module) {
411411
}
412412
}
413413
// Replace the current token with the completion
414-
session.editor.document.replaceRange(completion, start, end);
414+
// HACK (tracking adobe/brackets#1688): We talk to the private CodeMirror instance
415+
// directly to replace the range instead of using the Document, as we should. The
416+
// reason is due to a flaw in our current document synchronization architecture when
417+
// inline editors are open.
418+
session.editor._codeMirror.replaceRange(completion, start, end);
415419

416420
// Return false to indicate that another hinting session is not needed
417421
return false;

0 commit comments

Comments
 (0)