Fixes a crash when renaming import path of a JSON file#3196
Fixes a crash when renaming import path of a JSON file#3196Andarist wants to merge 1 commit intomicrosoft:mainfrom
Conversation
| if options.use == referenceUseRename && ast.IsSourceFile(decl) { | ||
| continue | ||
| } |
There was a problem hiding this comment.
I have tested the same patch in Strada and renaming the from "./x/package.json" resulted in the file itself being renamed too. That's definitely a desirable outcome but I'm not exactly sure what's the codepath leading to that filename rename - given it works... I wasn't exactly inclined to dig deeper.
The alternative fix would be to handle this in the loop here:
typescript-go/internal/ls/rename.go
Lines 82 to 92 in a4325da
The crash happens in getTextForRename
There was a problem hiding this comment.
I need to think a bit more about all this, but I think this fix is ok. We're missing support for file rename in Corsa right now (Strada's getEditsForFileRename), planning on porting that next. But I think the right behavior would be to return just a RenameFile in this case and then compute the edits in response to a willRenameFiles request from the client. So the fix looks right, but we don't have a good way right now to properly test this. I think I will leave this PR open and revisit once file rename is ported, if that's ok.
fixes a crash found here #3187 (comment) (it also crashes in Strada)