Skip to content

Commit

Permalink
lsp: Only offer directive completions when valid
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Jan 14, 2024
1 parent f4e3e84 commit 3dd5ed5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/esbonio/esbonio/server/features/directives/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@ async def completion(
if "directive" not in groups:
return await self.complete_options(context)

# Don't offer completions for targets
if (groups["name"] or "").startswith("_"):
return None

# Are we completing the directive's argument?
directive_end = context.match.span()[0] + len(groups["directive"])
complete_directive = groups["directive"].endswith("::")
complete_directive = groups["directive"].endswith(("::", "}"))

if complete_directive and directive_end < context.position.character:
return await self.complete_arguments(context)
Expand All @@ -108,7 +112,6 @@ async def complete_directives(

language = self.server.get_language_at(context.doc, context.position)
render_func = completion.get_directive_renderer(language, self._insert_behavior)

if render_func is None:
return None

Expand Down

0 comments on commit 3dd5ed5

Please sign in to comment.