Description
Prior to #237 if you started typing a function, and hit the first brace: {
then vscode automatically completed it for you, like so:
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:
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:
- remove the
{
suggested completion. Is there a use case for the language server telling the user what a{
does? - 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.