Skip to content

PR #237 introduced a brace completion bug for functions #239

Closed
@nikita-skobov

Description

@nikita-skobov

Prior to #237 if you started typing a function, and hit the first brace: { then vscode automatically completed it for you, like so:

example_before

After #237 when you hit the first brace: {, it calls our onCompletion function and the word is {, it finds matching words to { and it finds the { command:

example_after

Typically, after typing a brace, a user will want to hit enter to fill in the function body, whereas if the user hits enter, the completion fills in, and the user is left with:

my_function {{}

I have tested this bug out on a couple cases, and it only seems to come up on functions, ie: something like this:

for i in {}

does not trigger the { suggested completion,

and

echo ${}

works as expected.

This error seems to be present with all function declaration syntaxes such as:

my_function () {
my_function(){
my_function ()
{

function my_function() {
function my_function () {
function my_function {
function my_function ()
{

I can make a PR for this, but Im not sure what the best way to resolve this issue is:

My two ideas come to:

  1. remove the { suggested completion. Is there a use case for the language server telling the user what a { does?
  2. Otherwise, add a check here:
    if (word) {
      // Filter to only return suffixes of the current word
      return allCompletions.filter(item => item.label.startsWith(word))
    }

to check if the word === '{' then dont give the { completion.

Let me know which of these you think is better (or if theres another approach I haven't considered), and I can send a PR later.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions