meganrogge / template-string-converter

Autocorrect from quotes to backticks
MIT License
194 stars 24 forks source link

Cannot read property 'range' of undefined #5

Closed roblourens closed 4 years ago

roblourens commented 4 years ago

I noticed these errors repeated over and over when typing in a large multiline template string.

[2020-09-24 20:19:57.128] [renderer6] [error] Cannot read property 'range' of undefined: TypeError: Cannot read property 'range' of undefined
    at /Users/roblou/.vscode-insiders/extensions/meganrogge.template-string-converter-0.0.7/out/extension.js:22:38
    at Generator.next (<anonymous>)
    at /Users/roblou/.vscode-insiders/extensions/meganrogge.template-string-converter-0.0.7/out/extension.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/Users/roblou/.vscode-insiders/extensions/meganrogge.template-string-converter-0.0.7/out/extension.js:4:12)
    at /Users/roblou/.vscode-insiders/extensions/meganrogge.template-string-converter-0.0.7/out/extension.js:16:53
    at l.fire (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:45:801)
    at t.ExtHostDocuments.$acceptDirtyStateChanged (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:712:771)
    at t.ExtHostDocuments.$acceptModelSaved (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:712:514)
    at m._doInvokeHandler (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:867:707)
    at m._invokeHandler (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:867:399)

[...]

[2020-09-24 20:27:12.654] [renderer6] [error] Illegal argument: character must be non-negative: Error: Illegal argument: character must be non-negative
    at Object.t.illegalArgument (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:10:662)
    at new _ (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:508:424)
    at new _ (/Applications/Visual Studio Code - Insiders.app/Contents/Resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:506:436)
    at /Users/roblou/.vscode-insiders/extensions/meganrogge.template-string-converter-0.0.7/out/extension.js:25:33
    at Generator.next (<anonymous>)
    at /Users/roblou/.vscode-insiders/extensions/meganrogge.template-string-converter-0.0.7/out/extension.js:8:71
    at new Promise (<anonymous>)
meganrogge commented 4 years ago

As of now this only works for single line strings. I will work on this though and catch that exception in the meantime.

mjbvz commented 4 years ago

This happens for me when ever the file is saved (which happens a lot if auto save is enabled)

In the case of save, I believe onDidChangeTextDocument is fired but there may not be any contentChanges