brackets-typescript-code-intel
brackets-typescript-code-intel copied to clipboard
Codemirror changes break extension
It looks like this extension no longer does code completion because of recent changes to code mirror.
TypeScriptDocument.prototype.updateScriptWithChange = function (doc, change) {
// Special case: the range is no longer meaningful since the entire text was replaced
if (!change.from || !change.to) {
// Update all the script
this.updateScriptWithText(doc, doc.getText());
}
var minChar = this.getIndexFromPos(change.from, doc),
limChar = this.getIndexFromPos(change.to, doc),
newText = change.text.join('\n');
this.lsh.editScript(getScriptName(doc), minChar, limChar, newText);
};
In the code block above change
is now an array of changes and, as such, change.from
and change.to
have moved to elements of the array. This code tries to resolve positions for undefined
which fail causing other things to fail and code completion to stop workinig.
I was looking into fixing this but I am unsure of the previous CodeMirror behavior and how to fix this for the changes made. In the current CM behavior, change.from
and change.to
are not only elements of an array but are also objects themselves, containing ch
, line
, and sometimes xRel
properties. This code seems to check if change.from
or change.to
do not exist, so I am thinking the updated code would be if (change[0].from.ch === change[0].to.ch) { }
, going by the comment in the code. Is that correct?
/cc @tomsdev