fix: focus After when opening a diff file
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
- [x] jj conflict resolution with ui akin to the diff viewer
|
||||
- [ ] make selecting a file in the diff view file picker focus the after buffer instead of the before buffer
|
||||
- [x] make selecting a file in the diff view file picker focus the after buffer instead of the before buffer
|
||||
- [ ] improve the lsp hover floating window:
|
||||
- it should be taller
|
||||
- [ ] add `*` on word to highlights and searches in buffer in one action.
|
||||
- it should be taller
|
||||
- [ ] add the `*` action from vim on word to highlights and searches in buffer in one action.
|
||||
- [ ] 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.
|
||||
- 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.
|
||||
|
||||
+1
-1
@@ -420,7 +420,7 @@ Accepted LSP definitions center the selection's caret row once in the destinatio
|
||||
|
||||
A definition whose source range **overlaps an actual added, removed, or replaced line** stays in the same comparison and selects the correct file and side, loading file details on demand. For a location link, the symbol's full target range determines overlap and its selection range determines the caret: an unchanged declaration with a changed body still belongs in the comparison. Source coordinates belong to that side, including old paths for renames; navigation reveals the exact selection row, even when previously omitted, never the nearest excerpt. A wholly unchanged target opens a **new ordinary tab**, even when it is visible context or omitted text in a changed file. Files outside the comparison's changes also open in a new tab. The original comparison, pane layout, source caret, excerpts, and dirty buffers remain intact. Loaded targets share their existing text and undo history rather than reloading disk; references to snapshot URIs retain the historical text and read-only identity in the new tab, even after the comparison closes. Unreadable files, invalid UTF-8, invalid source ranges, and unsupported remote URIs do not create a tab or disturb the source.
|
||||
|
||||
Use the ordinary **file-picker/file-explorer actions and bindings**: Space `o` opens a floating picker, Space `e` opens/focuses the docked explorer, and Ctrl+w closes the focused picker/explorer and reclaims its width. Remapped bindings work too; Ctrl+e is no longer reserved by the diff. The changed-path catalog retains A/M/D/R markers and the normal compact tree, filtering, folder expansion, and configurable `tree`/`selection` navigation. It includes removed and historical paths without scanning the working directory. Enter toggles a folder or opens the selected comparison file and focuses its first visible text pane: After for added files, otherwise Before. While the explorer is hidden, Tab/Shift+Tab cycles between visible text panes only; a single-pane view keeps its focus.
|
||||
Use the ordinary **file-picker/file-explorer actions and bindings**: Space `o` opens a floating picker, Space `e` opens/focuses the docked explorer, and Ctrl+w closes the focused picker/explorer and reclaims its width. Remapped bindings work too; Ctrl+e is no longer reserved by the diff. The changed-path catalog retains A/M/D/R markers and the normal compact tree, filtering, folder expansion, and configurable `tree`/`selection` navigation. It includes removed and historical paths without scanning the working directory. Enter toggles a folder or opens the selected comparison file and focuses After when that pane exists; deleted files and other Before-only views focus Before. While the explorer is hidden, Tab/Shift+Tab cycles between visible text panes only; a single-pane view keeps its focus.
|
||||
|
||||
File rows show colored **A** (added, green), **M** (modified, yellow), **D** (removed, red), or **R** (renamed, cyan) markers in Tree and List views, including filtered results. Rename rows show `R old/path -> new/path`; directories have no file-status marker.
|
||||
|
||||
|
||||
+52
-2
@@ -1151,7 +1151,8 @@ impl DiffState {
|
||||
if let Some(path) = files.accept()
|
||||
&& self.select_file(&path)
|
||||
{
|
||||
self.focus = self.first_text_focus();
|
||||
self.focus = Focus::After;
|
||||
self.normalize_focus();
|
||||
let files = self.files.as_mut().expect("comparison picker");
|
||||
files.focused = false;
|
||||
self.files_visible = files.presentation == FilePresentation::Docked;
|
||||
@@ -3205,6 +3206,55 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn opening_diff_file_focuses_after_when_present() {
|
||||
for view_mode in [ViewMode::Split, ViewMode::Unified] {
|
||||
for presentation in [FilePresentation::Docked, FilePresentation::Floating] {
|
||||
for status in [
|
||||
FileStatus::Modified,
|
||||
FileStatus::Renamed,
|
||||
FileStatus::Added,
|
||||
FileStatus::Removed,
|
||||
] {
|
||||
let mut editor = editor();
|
||||
editor.set_diff_display_options(view_mode, crate::panes::SplitAxis::Vertical);
|
||||
open(&mut editor);
|
||||
let id = choose_pair(&mut editor);
|
||||
let mut changes = comparison();
|
||||
let index = match status {
|
||||
FileStatus::Modified | FileStatus::Renamed => 0,
|
||||
FileStatus::Added => 1,
|
||||
FileStatus::Removed => 2,
|
||||
};
|
||||
let mut file = changes.files.remove(index);
|
||||
file.status = status;
|
||||
let expected_text = file.after.join("\n");
|
||||
changes.files = vec![file];
|
||||
editor.apply_diff_result(id, Ok(Outcome::Comparison(changes)));
|
||||
if presentation == FilePresentation::Floating {
|
||||
text(&mut editor, " o");
|
||||
}
|
||||
editor.handle(Input::Enter);
|
||||
let diff = editor.diff().unwrap();
|
||||
assert_eq!(
|
||||
diff.focus,
|
||||
if status == FileStatus::Removed {
|
||||
Focus::Before
|
||||
} else {
|
||||
Focus::After
|
||||
},
|
||||
"{view_mode:?} {presentation:?} {status:?}",
|
||||
);
|
||||
assert!(!diff.files.as_ref().unwrap().focused);
|
||||
assert_eq!(diff.files_visible, presentation == FilePresentation::Docked);
|
||||
if status != FileStatus::Removed {
|
||||
assert_eq!(editor.context().text, expected_text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn added_file_picker_cancel_close_and_mouse_focus_use_after() {
|
||||
let mut editor = editor();
|
||||
@@ -3509,7 +3559,7 @@ mod tests {
|
||||
assert!(!picker.entries().nth(picker.selected).unwrap().is_dir);
|
||||
editor.handle(Input::Enter);
|
||||
assert_eq!(editor.diff().unwrap().file, 0);
|
||||
editor.handle(Input::BackTab);
|
||||
text(&mut editor, " e");
|
||||
editor.handle(Input::Char('i'));
|
||||
text(&mut editor, "x/y");
|
||||
editor.handle(Input::Enter);
|
||||
|
||||
@@ -8675,6 +8675,7 @@ mod tests {
|
||||
let mut diff = diff_comparison(vec![deletion_file(), added]);
|
||||
diff.handle(Input::Down);
|
||||
diff.handle(Input::Enter);
|
||||
diff.handle(Input::BackTab);
|
||||
for _ in 0..4 {
|
||||
diff.handle(Input::Right);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user