aboutsummaryrefslogtreecommitdiff
path: root/helix-view
diff options
context:
space:
mode:
authorwoojiq2023-08-08 13:17:29 +0000
committerGitHub2023-08-08 13:17:29 +0000
commitaa4d84a0b30fbe93882508c6d9dc8ca4c95341d0 (patch)
treece3615ac864edb7b1cf124c744e09d197ff81075 /helix-view
parentc1c71bb90edf8fe43584bb103e72bd0e81d36100 (diff)
Align view for background buffer opened with `alt-ret` (#7691)
* fix(picker): `alt-ret' changes cursor pos of current file, not new one Closes #7673 * fix other pickers * symbol pickers * diagnostick pickers This is done using the already patched `jump_to_location` method. * fix global and jumplist pickers * use `view` as old_id; make `align_view` method of `Action` * test(picker): basic <alt-ret> functionality * fix: picker integrational test * fix nit Co-authored-by: Michael Davis <mcarsondavis@gmail.com> --------- Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Diffstat (limited to 'helix-view')
-rw-r--r--helix-view/src/editor.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/helix-view/src/editor.rs b/helix-view/src/editor.rs
index 113102b6..af00864a 100644
--- a/helix-view/src/editor.rs
+++ b/helix-view/src/editor.rs
@@ -995,6 +995,13 @@ pub enum Action {
VerticalSplit,
}
+impl Action {
+ /// Whether to align the view to the cursor after executing this action
+ pub fn align_view(&self, view: &View, new_doc: DocumentId) -> bool {
+ !matches!((self, view.doc == new_doc), (Action::Load, false))
+ }
+}
+
/// Error thrown on failed document closed
pub enum CloseError {
/// Document doesn't exist