Completions aren't being offered unless first preceded by a space

Hi all,

I am having a problem in the Tailwind CSS extension. Completions are no longer offered when they are the first css class written in a HTML tag class attribute.

For example, <div class="m would not trigger completions to be shown. However, <div class="mt-5 m would because it is preceded by the space.

Any ideas on this? I don’t remember having this issue, so I don’t know if it’s something new with Nova or something I broke along the way. :smiley:


Hey Jason, could you post the (XML) code to the relevant completion provider? That might offer a clue.

Thanks for the reply Martin! The extension doesn’t actually use the XML method, but rather the JavaScript method for completions.

@logan are you able to confirm if this is an issue with Nova or if the API provides a way of dealing with this situation?

Interestingly the provideCompletionItems() method is being called, but the display of completion options isn’t being displayed. The relevant file can be found at tailwindcss-nova-ext/completion_provider.js at main · jasonplatts/tailwindcss-nova-ext · GitHub

Sorry folks. I think this is a problem I have created along the way. I tested an older version of the extension and the problem doesn’t exist. I’ll have to spend some time this weekend trying to figure out what I did :blush:

Just an update to anyone who may read this thread…The problem seems to be that the item.range was being set.

TL;DR; For anyone really interested. If I understand correctly, in previous versions of Nova, typing a hyphen would cause Nova to consider anything before the hyphen as a separate word, which caused incorrect autocompletions once the user had typed past a hyphen character. For example, typing “overflow-au” and then autocompleting at any point after would insert the text "overflow-overflow-auto” because overflow would be considered a separate word. So the item.range had to be set to provide the correct text replacement.

1 Like

So I had a similar issue and was very excited to try out your theory. In my case, it didn’t end up being a solution. I still needed to set an item.range for kebab-cased completions, or all but the last fragment wouldn’t be replaced. Also, I’m not conditionally setting this range only when more than the current “word” needs to be replaced, and completions still work fine when the range is set.

My current working theory for my case is that I was trying to helpfully format completions with JSON punctuation (e.g., ", :), and Nova was suppressing it when item.insertText began with one of those characters. I’d really love some clarification from Panic on why provided completions might not be displayed.