Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Codemirror changes break extension #11

Open
JeffryBooher opened this issue Jun 4, 2014 · 2 comments
Open

Codemirror changes break extension #11

JeffryBooher opened this issue Jun 4, 2014 · 2 comments

Comments

@JeffryBooher
Copy link

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.

@le717
Copy link
Contributor

le717 commented Sep 25, 2014

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?

@le717
Copy link
Contributor

le717 commented Sep 25, 2014

/cc @tomsdev

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants