pulsar-edit / pulsar

A Community-led Hyper-Hackable Text Editor
https://pulsar-edit.dev
Other
3.29k stars 138 forks source link

auto complete css dont work prety fine #1003

Open HelloWorldFR opened 5 months ago

HelloWorldFR commented 5 months ago

Thanks in advance for your bug report!

What happened?

the list of the autocomplete popup show only 1 item

Pulsar version

1.116

Which OS does this happen on?

🪟 Windows

OS details

windows 10

Which CPU architecture are you running this on?

x86_64/AMD64

What steps are needed to reproduce this?

With a new default install When i try to add the property in the 1st of the list, its dont show the liste

sample code: p { padding-right: 0px; background-color: red; } div { display: block; padding-right: 0px; } span { display: block; padding-right: 0px; }

Additional Information:

css

HelloWorldFR commented 5 months ago

No bug whith pulsar 1.105

savetheclocktower commented 5 months ago

Sadly, I think this is a side-effect of the new Tree-sitter CSS grammar. I described some of its difficulties in #601 — it makes bad guesses about how to do completions in situations where the tree is not syntactically valid because the user is still typing. I think that tree-sitter-css itself should improve to be better at this sort of thing, but in the meantime there's not much we can do except use a different system internally to make better guesses about what the user is typing.

You didn't notice this problem in 1.105 because we hadn't started using the new grammars. That means that you have a decent workaround: try one of the config changes in #883 (under “I want to go back to the old highlighting!"). I think you'll have to revert to the TextMate grammar, but maybe the other config block will work instead.

This is something that should be more actively on our radar, so I'll either create an issue to track this or change this issue to include more context about the problem.

savetheclocktower commented 5 months ago

This is what I mean:

Screenshot 2024-05-16 at 9 34 50 AM

I'm almost certainly about to type a property — something that starts with padding — but tree-sitter-css thinks it's a tag name. And though it technically could end up as a tag name, autocomplete-css should resolve that ambiguity by offering me properties and tag names that match.

Screenshot 2024-05-16 at 9 36 13 AM

Once the colon is present, tree-sitter-css now thinks that pad is likely part of a property. At this point, autocomplete-css will suggest property completions, but it's a bit annoying to have to type the colon first, so this isn't a reasonable workaround.