Sublime Forum

ST4 auto space and autocomplete behavior change

#1

I’m noticing two changes in ST4 that have (surprisingly) really blown up my work flow when I jump into CSS:

Issue 1: Autocomplete window pops up even before any characters are typed


So, when I get to the end of my element declaration and hit “enter” to start a new line (I start my opening brace on the next line), I’m constantly getting some random bit of css autocompleted. I tried adjusting the time before the autocomplete shows up, but that’s interrupted my work flow everywhere else. So, I’d love to be able to turn off the autcomplete if I haven’t started typing anything yet, but I can’t find an option for that.

Issue 2: Automatic space addition
When filling in css attributes, a space is being auto added after the colon. So, if I start typing “color:”, the autocomplete correctly pops up and has “color:” already selected, I hit “enter” and it autocompletes, but it adds a space after the colon whereas it has never done that before and I’m used to adding that in myself.
Thus, I’m constantly ending up with extra/unnecessary spaces. This one is a little less irritating and I may be able to get used to it, but if there is an option to turn this off, I would love to know what it is

0 Likes

#2

After a bunch of trial and error, I think I may have found a solution for the first problem:
"auto_complete_use_index": false,
I’m not sure what feature(s) I may be giving up by doing this, but the behavior seems to be back to what I am used to. Still can’t seem to figure out the extra space issue…

0 Likes

#3

Historically in ST3 the only completions you would see (unless also using a plugin of some sort) were symbols from files that you currently have open, and other symbols would not be provided.

auto_complete_use_index tells Sublime that it should use symbols from other files in the project to add completions to the AC panel when it appears, even if they’re not currently open, which could for example tell you about selectors from other files that you want to use in this one, for example. Turning the setting off reverts Sublime to the ST3 behaviour for this.

You may want to investigate adding:

`"auto_complete_when_likely": false

The idea being that Sublime tries to use heuristics to determine if you’re in a case where you might want AC based on the contents of files that it’s seen. It defaults to being turned on, so I would imagine that given the clue that CSS rules tend to have items after then, it’s trying to be helpful in a way that in this case it may not be.

You could also try this setting, which as described by the comment removes the ambiguity of the enter key in a situation like this by requiring you to choose the completion via tab instead, which is less likely to result in accidental completions (though this would probably be a muscle memory change):

	// By default, auto complete will commit the current completion on enter.
	// This setting can be used to make it complete on tab instead.
	// Completing on tab is generally a superior option, as it removes
	// ambiguity between committing the completion and inserting a newline.
	"auto_complete_commit_on_tab": false,

This is being done by the CSS package itself and it’s completion handler; it inserts the space for you if there isn’t one there, and will also insert the ; for you as well. There’s not currently an option to turn if off, but making a modification to the plugin that injects the completions is possible.

1 Like

#4

I’m seeing the same thing, and it’s making Sublime pretty hard to use. I’ve been using Sublime for like a decade but it’s only started happening this year.

  1. Auto complete popping up constantly for no reason, like after a semi-colon has ended the statement.
  2. That space after the CSS selector – I wonder if there’s a way to roll back to the pre-regression version of the CSS package?
0 Likes

#5
"auto_complete_when_likely": false

Does help quite a bit.

0 Likes

#6

Does it happen in safe mode? Specifically the auto-complete popping up after a ; usually hints at a plugin interfering.

0 Likes

#7

Is there a solution for the colon space situation? i can’t figure it out and it’s very upsetting. auto complete when likely does not help.

0 Likes

#8

You can add a user keybinding for the : key:
Preferences > Key Bindings

[
    { "keys": [":"], "command": "insert", "args": {"characters": ":"}, "context": [{"key": "selector", "operand": "source.css - meta.selector.css"}] },
]

or if you want to still add the semicolon at the end, just without the additional space:

[
    { "keys": [":"], "command": "insert_snippet", "args": {"contents": ":$0;"}, "context": [{"key": "selector", "operand": "source.css - meta.selector.css"}] },
]
1 Like