Unnamed repository; edit this file 'description' to name the repository.
| -rw-r--r-- | helix-term/src/application.rs | 14 | ||||
| -rw-r--r-- | helix-term/src/compositor.rs | 4 |
2 files changed, 15 insertions, 3 deletions
diff --git a/helix-term/src/application.rs b/helix-term/src/application.rs index c4e0bc3e..6c628669 100644 --- a/helix-term/src/application.rs +++ b/helix-term/src/application.rs @@ -1218,9 +1218,17 @@ impl Application { // If `Uri` gets another variant other than `Path` this may not be valid. let path = uri.as_path().expect("URIs are valid paths"); - let action = match take_focus { - Some(true) => helix_view::editor::Action::Replace, - _ => helix_view::editor::Action::VerticalSplit, + // Determine the focus strategy based on the current UI state and LSP request: + // 1. If there is no pop-up overlay, jump directly (Replace). + // 2. If there is a pop-up overlay, unless the LSP forces take_focus, only load in the background (Load) to prevent interruption of input. + // Note: We assume layer_count() == 1 means only the EditorView is present (no popups/overlays). + let action = if self.compositor.layer_count() == 1 { + helix_view::editor::Action::Replace + } else { + match take_focus { + Some(true) => helix_view::editor::Action::Replace, + _ => helix_view::editor::Action::Load, + } }; let doc_id = match self.editor.open(path, action) { diff --git a/helix-term/src/compositor.rs b/helix-term/src/compositor.rs index 266a8aec..bd7c98b7 100644 --- a/helix-term/src/compositor.rs +++ b/helix-term/src/compositor.rs @@ -220,6 +220,10 @@ impl Compositor { pub fn need_full_redraw(&mut self) { self.full_redraw = true; } + + pub fn layer_count(&self) -> usize { + self.layers.len() + } } // View casting, taken straight from Cursive |