From aa4d84a0b30fbe93882508c6d9dc8ca4c95341d0 Mon Sep 17 00:00:00 2001 From: woojiq Date: Tue, 8 Aug 2023 16:17:29 +0300 Subject: 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 functionality * fix: picker integrational test * fix nit Co-authored-by: Michael Davis --------- Co-authored-by: Michael Davis --- helix-view/src/editor.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'helix-view/src') 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 -- cgit v1.2.3-70-g09d2