fix: preserve visible declaration names under scope overlays
This commit is contained in:
@@ -14,7 +14,8 @@
|
|||||||
- [x] scroll viewport action (`ctrl+u|d`) scroll distance should be configurable.
|
- [x] scroll viewport action (`ctrl+u|d`) scroll distance should be configurable.
|
||||||
- [x] file picker file search should also be fuzzy (we should be able to use the same fuzzy implemented for diff view search, i believe)
|
- [x] file picker file search should also be fuzzy (we should be able to use the same fuzzy implemented for diff view search, i believe)
|
||||||
- [x] diff view: labels are currently attached also when scrolling the view port horizontally (such that e.g. a function name is not fully visible in the viewport), which is good, but it currently attaches at that line, thus pushing down the function by one line, which causes a one-line jump when scrolling horizontally.
|
- [x] diff view: labels are currently attached also when scrolling the view port horizontally (such that e.g. a function name is not fully visible in the viewport), which is good, but it currently attaches at that line, thus pushing down the function by one line, which causes a one-line jump when scrolling horizontally.
|
||||||
- horizontal labels overlay the row above the declaration without shifting source rows; hide the label on the first visible row to preserve the pane border.
|
- horizontal labels overlay the row above the declaration without shifting source rows; hide the label when it would cover the pane border or a visible declaration name.
|
||||||
|
- [ ] diff view: add change count (added and removed) to the tab name. format could be something like `Diff · <changes> · <buffer name>`.
|
||||||
- [ ] diff view: github integration (code review) - add comments on a pr, add review comments at specific lines of files, request changes, approve pr, etc.
|
- [ ] diff view: github integration (code review) - add comments on a pr, add review comments at specific lines of files, request changes, approve pr, etc.
|
||||||
- [ ] diff view: local review comments (same features as for github reviews) that allows review of local changes to deliver specific reviews to ai agents used for coding.
|
- [ ] diff view: local review comments (same features as for github reviews) that allows review of local changes to deliver specific reviews to ai agents used for coding.
|
||||||
- design question: would this require a server that the agent can interact with, or would local review files be fine? don't want to use server client stuff, if it would be easier and better to just use local files.
|
- design question: would this require a server that the agent can interact with, or would local review files be fine? don't want to use server client stuff, if it would be easier and better to just use local files.
|
||||||
|
|||||||
@@ -450,6 +450,7 @@ Review marks belong only to the open comparison and survive filtering, file navi
|
|||||||
Text panes show change excerpts with **10 unchanged lines above and below** each change, preserving original file line numbers. Overlapping or touching excerpts merge; omitted stretches show an unchanged-line count in both panes. Files with only metadata changes show their notice or “No text changes” rather than unrelated source.
|
Text panes show change excerpts with **10 unchanged lines above and below** each change, preserving original file line numbers. Overlapping or touching excerpts merge; omitted stretches show an unchanged-line count in both panes. Files with only metadata changes show their notice or “No text changes” rather than unrelated source.
|
||||||
|
|
||||||
**Scope labels** identify named enclosing functions/classes and containers, such as `impl Review › run`. Muted, unnumbered rows supply context when the declaration is vertically outside that pane's viewport; scrolling it back into view removes the label and reclaims its row. If an unwrapped declaration remains vertically visible but its symbol is clipped horizontally, its label instead overlays the preceding content row. On the first visible row, that label is hidden so the pane border stays intact. Horizontal scrolling never inserts a row or shifts source text; scrolling the symbol back into view restores the covered row. Decorators alone do not count as the declaration name. Visibility follows source columns and wrapped segments independently for each side. Each split side uses its own source, so renamed functions keep distinct old/new names. Unified labels use `−` for Before, `+` for After, and `±` for shared names. Narrow panes prefer the innermost name. Labels are presentation only: motions, selections, copying, editing, and line jumps retain original source coordinates. Context comes from the existing Tree-sitter trees, including supported injected code, without requiring an LSP; unsupported syntax gets no guessed label.
|
**Scope labels** identify named enclosing functions/classes and containers, such as `impl Review › run`. Muted, unnumbered rows supply context when the declaration is vertically outside that pane's viewport; scrolling it back into view removes the label and reclaims its row. If an unwrapped declaration remains vertically visible but its symbol is clipped horizontally, its label instead overlays the preceding content row. On the first visible row, that label is hidden so the pane border stays intact. Horizontal scrolling never inserts a row or shifts source text; scrolling the symbol back into view restores the covered row. Decorators alone do not count as the declaration name. Visibility follows source columns and wrapped segments independently for each side. Each split side uses its own source, so renamed functions keep distinct old/new names. Unified labels use `−` for Before, `+` for After, and `±` for shared names. Narrow panes prefer the innermost name. Labels are presentation only: motions, selections, copying, editing, and line jumps retain original source coordinates. Context comes from the existing Tree-sitter trees, including supported injected code, without requiring an LSP; unsupported syntax gets no guessed label.
|
||||||
|
Overlays never cover a visible declaration name on the preceding row, including a different Before/After declaration in unified view; the label is hidden instead.
|
||||||
Within an excerpt, additional hunks and alignment gaps do not repeat an unchanged scope label. A new excerpt or an actual scope change gets a fresh label when needed; sticky context is retained independently for each side.
|
Within an excerpt, additional hunks and alignment gaps do not repeat an unchanged scope label. A new excerpt or an actual scope change gets a fresh label when needed; sticky context is retained independently for each side.
|
||||||
|
|
||||||
In **Normal mode** with a text pane focused, **`[` expands above** and **`]` expands below** the excerpt containing the caret, revealing up to **15 lines** per keypress in either pane. In editable After's Insert mode these keys insert literal text. Expansion clamps at file boundaries and merges excerpts when they meet. Existing visible source stays anchored. Opening a file resets its excerpts to the configured initial context. Live edits recompute changes while retaining expanded context; the caret stays visible even when the last text change is reverted.
|
In **Normal mode** with a text pane focused, **`[` expands above** and **`]` expands below** the excerpt containing the caret, revealing up to **15 lines** per keypress in either pane. In editable After's Insert mode these keys insert literal text. Expansion clamps at file boundaries and merges excerpts when they meet. Existing visible source stays anchored. Opening a file resets its excerpts to the configured initial context. Live edits recompute changes while retaining expanded context; the caret stays visible even when the last text change is reverted.
|
||||||
|
|||||||
+53
@@ -4166,6 +4166,31 @@ fn draw_diff_scope_labels(
|
|||||||
let Some(y) = y.checked_sub(1).filter(|&y| y >= content.y) else {
|
let Some(y) = y.checked_sub(1).filter(|&y| y >= content.y) else {
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
|
let previous = &viewport.rows[screen - 1];
|
||||||
|
let previous_focus = if unified {
|
||||||
|
diff.display_focus(previous.position.display)
|
||||||
|
.unwrap_or(focus)
|
||||||
|
} else {
|
||||||
|
focus
|
||||||
|
};
|
||||||
|
let previous_side = usize::from(previous_focus == Focus::After);
|
||||||
|
if previous.scope == [false; 2]
|
||||||
|
&& let Some(previous_scope) =
|
||||||
|
syntax.scopes(diff, previous.position.display)[previous_side]
|
||||||
|
&& diff.display_source_row(previous_focus, previous.position.display)
|
||||||
|
== Some(previous_scope.name.row)
|
||||||
|
{
|
||||||
|
let source = if previous_side == 0 {
|
||||||
|
&file.before
|
||||||
|
} else {
|
||||||
|
&file.after
|
||||||
|
};
|
||||||
|
let prefix = &source[previous_scope.name.row][..previous_scope.name.column];
|
||||||
|
let column = display_column(prefix, usize::MAX);
|
||||||
|
if lefts[pane] <= column && column < lefts[pane].saturating_add(width) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
y
|
y
|
||||||
} else {
|
} else {
|
||||||
if !row.scope[side] {
|
if !row.scope[side] {
|
||||||
@@ -8349,6 +8374,34 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn diff_scope_overlay_preserves_visible_declaration_above() {
|
||||||
|
let before = "pub fn old_name() {\n shared_call_with_a_long_argument_name();\n}\n";
|
||||||
|
let after = "fn new_name() {\n shared_call_with_a_long_argument_name();\n}\n";
|
||||||
|
for focus in [Focus::Before, Focus::After] {
|
||||||
|
let mut file = syntax_diff_file("scope.rs", before, after);
|
||||||
|
file.hunks = crate::diff::line_hunks(&file.before, false, &file.after, false);
|
||||||
|
let mut diff = diff_comparison(vec![file]);
|
||||||
|
diff.files_visible = false;
|
||||||
|
diff.set_view_mode(ViewMode::Unified);
|
||||||
|
diff.focus = focus;
|
||||||
|
diff.top = diff.source_display_row(Focus::Before, 0).unwrap();
|
||||||
|
diff.left_before = 4;
|
||||||
|
diff.left_after = 4;
|
||||||
|
let mut terminal = Terminal::new(ratatui::backend::TestBackend::new(100, 20)).unwrap();
|
||||||
|
let mut panels = WheelPanels::default();
|
||||||
|
render_diff(&mut terminal, &diff, &mut panels);
|
||||||
|
let pane = usize::from(focus == Focus::After);
|
||||||
|
let area = diff_inner(panels.diff.as_ref().unwrap().regions[pane + 1].0);
|
||||||
|
let first = pane_screen(&terminal, Rect::new(area.x, area.y, area.width, 1));
|
||||||
|
assert!(
|
||||||
|
first.contains("fn old_name()"),
|
||||||
|
"Visible declaration was covered: {first}"
|
||||||
|
);
|
||||||
|
assert!(!first.contains("+ new_name"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn diff_scope_labels_follow_declaration_visibility() {
|
fn diff_scope_labels_follow_declaration_visibility() {
|
||||||
let before = "@decorate()\nclass PolicyActiveStatusEnum(BaseEnum):\n ACTIVE = 1\n EXPIRED = 2\n FUTURE = 3\n UNKNOWN = 4\n";
|
let before = "@decorate()\nclass PolicyActiveStatusEnum(BaseEnum):\n ACTIVE = 1\n EXPIRED = 2\n FUTURE = 3\n UNKNOWN = 4\n";
|
||||||
|
|||||||
Reference in New Issue
Block a user