Skip to content

Commit

Permalink
[HTML] Improvements to attribute completions (#2433)
Browse files Browse the repository at this point in the history
* [HTML] Allow the user to type > at the end of a tag to "overwrite"

If for some reason a user wants a second >, they can press that key
twice.

* [HTML] Improve attribute completion flow

Always adds a field to attribute completions to provide a better typing
experience for users. This allows the user to press [tab] instead of
typing a close quote, or close quote and greater than symbol.
  • Loading branch information
wbond committed Aug 18, 2020
1 parent 9cd8601 commit 950c064
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions HTML/Default.sublime-keymap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
{ "keys": [">"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
[
{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
{ "key": "following_text", "operator": "regex_contains", "operand": "^>", "match_all": true },
{ "key": "selector", "operator": "equal", "operand": "punctuation.definition.tag.end.html", "match_all": true },
]
},
]
3 changes: 3 additions & 0 deletions HTML/html_completions.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,9 @@ def attribute_completions(self, view, pt, prefix):
# add a space if not there
suffix = ' '

# ensure the user can always tab to the end of the completion
suffix += '$0'

# got the tag, now find all attributes that match
return sublime.CompletionList(
[
Expand Down

0 comments on commit 950c064

Please sign in to comment.