From bdcd4d9411655ab69245d803e88f88cc278127da Mon Sep 17 00:00:00 2001 From: Poliorcetics Date: Sat, 11 Mar 2023 03:32:14 +0100 Subject: Feat: LSP Type Hints (#5934) * misc: missing inline, outdated link * doc: Add new theme keys and config option to book * fix: don't panic in Tree::try_get(view_id) Necessary for later, where we could be receiving an LSP response for a closed window, in which case we don't want to crash while checking for its existence * fix: reset idle timer on all mouse events * refacto: Introduce Overlay::new and InlineAnnotation::new * refacto: extract make_job_callback from Context::callback * feat: add LSP display_inlay_hint option to config * feat: communicate inlay hints support capabilities of helix to LSP server * feat: Add function to request range of inlay hint from LSP * feat: Save inlay hints in document, per view * feat: Update inlay hints on document changes * feat: Compute inlay hints on idle timeout * nit: Add todo's about inlay hints for later * fix: compute text annotations for current view in view.rs, not document.rs * doc: Improve Document::text_annotations() description * nit: getters don't use 'get_' in front * fix: Drop inlay hints annotations on config refresh if necessary * fix: padding theming for LSP inlay hints * fix: tracking of outdated inlay hints should not be dependant on document revision (because of undos and such) * fix: follow LSP spec and don't highlight padding as virtual text * config: add some LSP inlay hint configs--- helix-view/src/tree.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'helix-view/src/tree.rs') diff --git a/helix-view/src/tree.rs b/helix-view/src/tree.rs index 5ec2773d..e8afd204 100644 --- a/helix-view/src/tree.rs +++ b/helix-view/src/tree.rs @@ -278,16 +278,15 @@ impl Tree { self.try_get(index).unwrap() } - /// Try to get reference to a [View] by index. Returns `None` if node content is not a [Content::View] - /// # Panics + /// Try to get reference to a [View] by index. Returns `None` if node content is not a [`Content::View`]. /// - /// Panics if `index` is not in self.nodes. This can be checked with [Self::contains] + /// Does not panic if the view does not exists anymore. pub fn try_get(&self, index: ViewId) -> Option<&View> { - match &self.nodes[index] { - Node { + match self.nodes.get(index) { + Some(Node { content: Content::View(view), .. - } => Some(view), + }) => Some(view), _ => None, } } -- cgit v1.2.3-70-g09d2