fix(tui): refine action span priority and in-place line alignment - #62
Merged
Conversation
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.
Problem
var fc = func(...)got refactored tofc := func(...), the innerfunc_literalwas parsed as aMoveaction because its parent changed fromvar_spectoshort_var_declaration.AlignLinesflagged the whole block as an unalignable move, creating diagonal filler lines (///) on both sides and splitting the function body into two separated blocks instead of rendering line 850 side-by-side.deleteofvar_declaration) were taking visual priority over inner child highlights (like a 129-bytemoveoffunc_literal).mergeAllSpanswas also dropping the underlying AST byte span when merging adjacent line highlights, creating fake single-line lengths that swallowed inner action highlights.What Changed
isDisplacedMoveininternal/serialize/align.goto calculate line offsets relative to the nearest mapped enclosing container. If a node stays inside the same mapped function or block at the same relative line offset, it is recognized as an in-place structural shift rather than a relocated move, soAlignLinespairs lines side-by-side with zero diagonal filler lines inside the function.totalLentospanininternal/tui/highlight.go, propagatingmax(curr.totalLen, next.totalLen)when merging adjacent line highlights so wider container spans don't drop their true total length.renderStyledLineininternal/tui/view.goto select highlights based ontotalLenso narrower inner AST actions override wider outer container spans, with action kind tie-breaking preferring specificmoveandupdateactions over containerinsertanddelete.expected.jsonfiles across integration test fixtures to match the improved side-by-side line alignment.Visual Comparison:
Example :-
tests/testdata/go_gin_fix_lintBefore
After