Repository navigation
fix: deduplicate rename edits for dynamic imports with .ts specifiers - #65512
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Open
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
刘亦达 (zhengdaodeguL) wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #65505
Background
Renaming a file loaded by a dynamic
import("./file.ts")(withallowImportingTsExtensions) makes the language server panic and exit(status 2):
panic: changes overlap: {{0 34} {0 47}} and {{0 34} {0 47}}.updateImportsForFileRenamequeues one edit persourceFile.Imports()entry, and the dynamic import produces the same specifier-range edit twice;
change.Tracker.GetChangespanics on the duplicate before the LSP layer'slater deduplication can run. Static imports and
.jsspecifiers only produceone edit and do not panic.
Change
Deduplicate identical import edits per source file in
updateImportsForFileRename, keyed by text range + replacement text. Aconflicting replacement at the same range still passes through to the
existing overlap check. Adds a fourslash regression test covering the
dynamic
.tsimport case, asserting exactly one edit with new text./sub/moved.ts.Verification
go test ./internal/fourslash/tests -run '^TestGetEditsForFileRename'—pass (includes the new regression test; the new test fails on base code
with the panic).
status 2 with the
changes overlappanic; after the fix theworkspace/willRenameFilesresponse contains exactly one edit(
./sub/moved.ts) and the server keeps running. The.jsspecifiercontrol case still returns one edit.
gofmt -lclean on both changed files;git diff --checkclean.Not run: full
npx hereby test(too large for this environment; only thetargeted Go tests were run),
npx hereby lint,npx hereby check:format.