feat(diff): implement dedicated line mode diffing functionality#152
Open
gullit-cw wants to merge 1 commit intosergi:masterfrom
Open
feat(diff): implement dedicated line mode diffing functionality#152gullit-cw wants to merge 1 commit intosergi:masterfrom
gullit-cw wants to merge 1 commit intosergi:masterfrom
Conversation
- Add DiffLineMode method for always-on line mode diffing - Introduce DiffFunction type for flexible diff computation - Add DiffCleanupLineBased for line-specific diff optimization - Refactor diffMainRunes to use closure-based approach - Update Go version to 1.24 and clean up dependencies - Add comprehensive test coverage for new functionality
83e187c to
0569de3
Compare
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.
Summary
This PR implements a dedicated line mode diffing functionality for the go-diff library, providing users with a more efficient and predictable way to perform line-based text comparisons.
Changes
New Features
DiffLineModemethod: A new public method that always uses line mode regardless of text length, providing consistent behavior for line-based diffing scenariosDiffFunctiontype: A new function type that encapsulates diff computation logic, enabling more flexible and testable diff implementationsDiffCleanupLineBasedmethod: Specialized cleanup function for line-based diffs that merges consecutive operations and removes trivial equalitiesRefactoring
DiffMainRunes: Refactored to use closure-based approach for better encapsulation of deadline and line mode logicdiffCompute: Updated to use the newDiffFunctiontype for more flexible diff computationInfrastructure
Benefits
DiffLineModeprovides consistent behavior regardless of input sizeTesting
DiffLineModefunctionalityUsage Example
Breaking Changes
None. This is a purely additive change that maintains full backward compatibility.
Related Issues
This implementation addresses the need for more efficient and predictable line-based diffing in scenarios where character-level precision is not required.