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

Commit

Permalink
Merge pull request #3711 from adobe/nj/issue-3709
Browse files Browse the repository at this point in the history
Hack yet another place where we need to use _codeMirror.replaceRange()...
  • Loading branch information
eztierney committed May 3, 2013
2 parents 20c7491 + 91ffeb2 commit 60dbbce
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/document/DocumentManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,14 @@ define(function (require, exports, module) {
* given new text; if text == "", then the entire range is effectively deleted. If 'end' is omitted,
* then the new text is inserted at that point and all existing text is preserved. Line endings will
* be rewritten to match the document's current line-ending style.
*
* IMPORTANT NOTE: Because of #1688, do not use this in cases where you might be
* operating on a linked document (like the main document for an inline editor)
* during an outer CodeMirror operation (like a key event that's handled by the
* editor itself). A common case of this is code hints in inline editors. In
* such cases, use `editor._codeMirror.replaceRange()` instead. This should be
* fixed when we migrate to use CodeMirror's native document-linking functionality.
*
* @param {!string} text Text to insert or replace the range with
* @param {!{line:number, ch:number}} start Start of range, inclusive (if 'to' specified) or insertion point (if not)
* @param {?{line:number, ch:number}} end End of range, exclusive; optional
Expand Down
6 changes: 5 additions & 1 deletion src/extensions/default/JavaScriptCodeHints/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,11 @@ define(function (require, exports, module) {
}
}
// Replace the current token with the completion
session.editor.document.replaceRange(completion, start, end);
// HACK (tracking adobe/brackets#1688): 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.
session.editor._codeMirror.replaceRange(completion, start, end);

// Return false to indicate that another hinting session is not needed
return false;
Expand Down

0 comments on commit 60dbbce

Please sign in to comment.