sublime-text-plugin icon indicating copy to clipboard operation
sublime-text-plugin copied to clipboard

[Vue] Inserts attribute inside interpolation on pressing dot

Open rchl opened this issue 5 years ago • 9 comments

Pressing dot in this context inserts a class attribute which is pretty wrong:

Screenshot 2020-08-27 at 15 41 07 Screenshot 2020-08-27 at 15 42 24

rchl avatar Aug 27 '20 13:08 rchl

Oh, I’ve just copy-pasted this feature from previous Emmet plugin. You can disable it with auto_id_class preference

sergeche avatar Aug 27 '20 13:08 sergeche

It doesn't insert an attribute if cursor is not exactly beneath the closing quote Screenshot 2020-08-27 at 15 59 17

But in any case, maybe the feature should not be enabled by default or the scopes where it triggers should be tweaked (although it might be tricky here).

rchl avatar Aug 27 '20 14:08 rchl

Oh, I’ve just copy-pasted this feature from previous Emmet plugin. You can disable it with auto_id_class preference

Could you give an example of the code please?

I've been trying to make a twig template and cannot currently write any Twig code that involves a .... which is a lot of it.

paulalden avatar Aug 28 '20 09:08 paulalden

@prwhitehead go to Preferences > Package Settings > Emmet > Settings menu item and set auto_id_class to false. Also, please give a Twig template sample where dot behaves incorrectly so I can tweak scopes

sergeche avatar Aug 28 '20 09:08 sergeche

BTW. Here is another tricky example where typing a dot would insert an attribute: Screenshot 2020-08-28 at 12 10 49

It's common to type dot in this place to insert @click.prevent for example.

Unfortunately, the scopes don't seem to make this case any different from a normal case...

rchl avatar Aug 28 '20 10:08 rchl

I suppose a good heuristic might be to only trigger this action when the cursor is preceded by white space.

rchl avatar Aug 28 '20 10:08 rchl

@rchl yes, was thinking about it too

sergeche avatar Aug 28 '20 10:08 sergeche

please give a Twig template sample where dot behaves incorrectly so I can tweak scopes

I found that the default behaviour is when the cursor is inside twig brackets {% ... %} or {{ ... }} then any keydown of . will cause class="" to be inserted. Outside of the twig brackets, this behaviour does not occur.

A snippet is:

 {% if entry.%}
 {{ entry.}} 

This is turned into:

{% if entry class=""%}
{{ entry class=""}}

Incase its a settings related issue, my keymap file is as follows:

[
	{ "keys": ["super+e"], "args": { "action": "expand_abbreviation" }, "command": "run_emmet_action", "context": [{"key": "emmet_action_enabled.expand_abbreviation"}]},
{ "keys": ["super+shift+a"], "command": "alignment" },

{ "keys": ["super+t"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["super+p"], "command": "show_overlay", "args": {"overlay": "goto", "show_files": true} },
{ "keys": ["super+shift+p"], "command": "show_overlay", "args": {"overlay": "command_palette"} },
{ "keys": ["super+ctrl+p"], "command": "prompt_select_workspace" },
{ "keys": ["super+r"], "command": "show_overlay", "args": {"overlay": "goto", "text": "@"} },
{ "keys": ["super+g"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
{ "keys": ["f12"], "command": "goto_definition" },
{ "keys": ["super+alt+down"], "command": "goto_definition" },
{ "keys": ["super+ctrl+f"], "command": "toggle_full_screen" },
{ "keys": ["super+ctrl+shift+f"], "command": "toggle_distraction_free" },
{ "keys": ["super+f"], "command": "show_panel", "args": {"panel": "replace", "reverse": false} },
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["alt+up"], "command": "swap_line_up" },
	{ "keys": ["alt+down"], "command": "swap_line_down" },
	{
			"keys": ["super+e"],
			"command": "emmet_expand_abbreviation"
	}
]

paulalden avatar Aug 28 '20 11:08 paulalden

Disabled auto_id_class by default in v2.1.15

sergeche avatar Aug 28 '20 14:08 sergeche