slint icon indicating copy to clipboard operation
slint copied to clipboard

lsp: FIx indentation inconsistency and multi-word keyword completion repetition bug

Open TheBearodactyl opened this issue 5 months ago • 9 comments

This PR:

  1. Makes the formatter use 2 spaces instead of 4 to match the tree-sitter indentation
  2. Fixes completion repetition on typing past the first word in a multi-word keyword (e.g. completing in p as opposed to in results in in in property where it should result in in property)

The new function in completion.rs could probably be smaller which is why I'm opening this as a draft

TheBearodactyl avatar Jul 23 '25 00:07 TheBearodactyl

Before:

https://github.com/user-attachments/assets/fab3556b-01f3-4a67-b63e-43848d1ad6bd

After:

https://github.com/user-attachments/assets/2c628a2b-c424-4bf8-934e-ef940843ffb7

TheBearodactyl avatar Jul 23 '25 01:07 TheBearodactyl

forgot to update the tests, one sec

TheBearodactyl avatar Jul 23 '25 01:07 TheBearodactyl

This is vim/nvim I assume? I think VSCode and helix both work fine with 4 spaces, so we should fix the tree-sitter based indentation in vim :-) And it would unbreak many of the failing tests, too:-)

I do like your completion suggestion a lot though!

hunger avatar Jul 23 '25 11:07 hunger

This is vim/nvim I assume? I think VSCode and helix both work fine with 4 spaces, so we should fix the tree-sitter based indentation in vim :-) And it would unbreak many of the failing tests, too:-)

I do like your completion suggestion a lot though!

oh i already fixed all but 3 of the tests

TheBearodactyl avatar Jul 23 '25 17:07 TheBearodactyl

i can definitely revert them though

TheBearodactyl avatar Jul 23 '25 17:07 TheBearodactyl

image

TheBearodactyl avatar Jul 23 '25 17:07 TheBearodactyl

also i might fix it to not remove newlines as well since removing them makes the code too compact

TheBearodactyl avatar Jul 23 '25 20:07 TheBearodactyl

Sorry for taking so long to look at your PR.

Makes the formatter use 2 spaces instead of 4 to match the tree-sitter indentation

We shouldn't change this like that as it would force to reformat everyone's code, and many people prefer 4 spaces. If anything this could be a setting.

Fixes completion repetition on typing past the first word in a multi-word keyword (e.g. completing in p as opposed to in results in in in property where it should result in in property)

This makes sense. Somehow this works fine on vscode, but we should be fixing it for editor that don't behave like that. There could also be tests for that behavior.

ogoffart avatar Dec 09 '25 07:12 ogoffart

I'll fix the PR up later this week

TheBearodactyl avatar Dec 11 '25 02:12 TheBearodactyl