perf(vscode): replace fast-diff with custom character-by-character alignment algorithm#5849
Merged
johnsoncodehk merged 6 commits intomasterfrom Dec 11, 2025
Merged
perf(vscode): replace fast-diff with custom character-by-character alignment algorithm#5849johnsoncodehk merged 6 commits intomasterfrom
fast-diff with custom character-by-character alignment algorithm#5849johnsoncodehk merged 6 commits intomasterfrom
Conversation
fast-diff with custom character-by-character alignment algorithm
johnsoncodehk
added a commit
that referenced
this pull request
Dec 18, 2025
…alignment algorithm (#5849)
johnsoncodehk
added a commit
that referenced
this pull request
Dec 18, 2025
…alignment algorithm (#5849)
johnsoncodehk
added a commit
that referenced
this pull request
Dec 18, 2025
…alignment algorithm (#5849)
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.
Note: The code implementation was written manually, but the tests and this PR summary were created with AI assistance.
Summary
This PR removes the dependency on
fast-diffand replaces it with a custom lightweight character alignment algorithm for the range formatting feature in the VS Code extension.Changes
fast-difffrompackage.json(reducing bundle size and dependencies)rangeFormatting.tsthat:Algorithm Details
The new approach uses two while loops:
The algorithm considers:
Known Limitations
This implementation is optimized for formatting operations (primarily whitespace changes) rather than arbitrary content transformations. It works well for:
It has limitations with:
Benefits
restrictFormattingEditsToRangeTesting
Added comprehensive test coverage including edge cases for whitespace handling, empty selections, boundary conditions, and documented known limitations.