perf(vscode): replace fast-diff with custom character-by-character alignment algorithm
#5849
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.