From 379a7c7c59b8f051efa320a2f4fa2901423e77c9 Mon Sep 17 00:00:00 2001 From: ef3d0c3e Date: Sun, 3 Nov 2024 10:54:27 +0100 Subject: [PATCH] Fix variables in LSP --- src/document/variable.rs | 2 +- src/elements/toc.rs | 5 ++--- src/lsp/hints.rs | 4 +++- src/lsp/semantic.rs | 4 +++- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/document/variable.rs b/src/document/variable.rs index 0a59237..4a1f9bc 100644 --- a/src/document/variable.rs +++ b/src/document/variable.rs @@ -52,7 +52,7 @@ impl Variable for BaseVariable { fn parse<'a>(&self, state: &ParserState, _location: Token, document: &'a dyn Document<'a>) { let source = Rc::new(VirtualSource::new( self.location().clone(), - self.name().to_string(), + format!(":VAR:{}", self.name()), self.to_string(), )); diff --git a/src/elements/toc.rs b/src/elements/toc.rs index a8a4109..6e4e667 100644 --- a/src/elements/toc.rs +++ b/src/elements/toc.rs @@ -66,9 +66,8 @@ impl Element for Toc { } } - if sections.is_empty() - { - return Ok("".into()) + if sections.is_empty() { + return Ok("".into()); } match compiler.target() { diff --git a/src/lsp/hints.rs b/src/lsp/hints.rs index dcc7164..9f7c4be 100644 --- a/src/lsp/hints.rs +++ b/src/lsp/hints.rs @@ -45,7 +45,9 @@ impl<'a> Hints<'a> { lsp: &'a Option>, original_source: Rc, ) -> Option { - if source.name().starts_with(":LUA:") && source.downcast_ref::().is_some() { + if (source.name().starts_with(":LUA:") || source.name().starts_with(":VAR:")) + && source.downcast_ref::().is_some() + { return None; } diff --git a/src/lsp/semantic.rs b/src/lsp/semantic.rs index 77ec64f..82ffad6 100644 --- a/src/lsp/semantic.rs +++ b/src/lsp/semantic.rs @@ -320,7 +320,9 @@ impl<'a> Semantics<'a> { lsp: &'a Option>, original_source: Rc, ) -> Option<(Self, Ref<'a, Tokens>)> { - if source.name().starts_with(":LUA:") && source.downcast_ref::().is_some() { + if (source.name().starts_with(":LUA:") || source.name().starts_with(":VAR:")) + && source.downcast_ref::().is_some() + { return None; }