Skip to content

Commit

Permalink
Update HTML tag completion handling, typo fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jcberquist committed Dec 17, 2024
1 parent e63db9f commit b0bbcd3
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 11 deletions.
31 changes: 26 additions & 5 deletions cfml_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class CustomHtmlTagCompletions(html_completions.HtmlTagCompletions):
"""
There is no text.html scope in <cffunction> bodies, so this
allows the HTML completions to still function there
uses Default Packages HtmlTagCompletions code
"""

def on_query_completions(self, view, prefix, locations):
Expand All @@ -91,9 +93,28 @@ def on_query_completions(self, view, prefix, locations):
if not view.match_selector(locations[0], selector):
return None

# check if we are inside a tag
is_inside_tag = view.match_selector(
locations[0], "meta.tag - punctuation.definition.tag.begin"
)
pt = locations[0] - len(prefix) - 1
ch = view.substr(pt)

if ch == '&':
return self.entity_completions

if ch == '<':
# If the caret is within tag, complete only tag names.
# see: https://github.com/sublimehq/sublime_text/issues/3508
if view.match_selector(locations[0], "meta.tag"):
return self.tag_name_completions
return self.tag_completions

# Note: Exclude opening punctuation to enable abbreviations
# if the caret is located directly in front of a html tag.
if view.match_selector(locations[0], "meta.function.body.tag.cfml meta.tag - meta.string - punctuation.definition.tag.begin"):
if ch in ' \f\n\t':
return self.attribute_completions(view, locations[0], prefix)
return None

if view.match_selector(locations[0], "meta.function.body.tag.cfml - meta.tag, meta.function.body.tag.cfml punctuation.definition.tag.begin"):
# Expand tag and attribute abbreviations
return self.expand_tag_attributes(view, locations) or self.tag_abbreviations

return self.get_completions(view, prefix, locations, is_inside_tag)
return None
12 changes: 6 additions & 6 deletions src/plugins_/applicationcfc/json/methods_docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,24 @@
]
},
"onerror": {
"header": "<span class=\"entity-name-function\">onError()",
"body": "This method is triggered when a uncaught exception occurs in this application context. As arguments you get the exception (cfcatch block) and the eventNam</span>e.",
"header": "<span class=\"entity-name-function\">onError</span>()",
"body": "This method is triggered when a uncaught exception occurs in this application context. As arguments you get the exception (cfcatch block) and the eventName.",
"links": [
{ "href": "http://docs.lucee.org/guides/cookbooks/application-context-basic.html", "text": "docs.lucee.org/guides/cookbooks/application-context-basic.html"},
{ "href": "https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/onerror.html", "text": "helpx.adobe.com onerror.html"}
]
},
"onabort": {
"header": "<span class=\"entity-name-function\">onAbort()",
"body": "This method is triggered when a request is ended with help of the tag <cfabort</span>>.",
"header": "<span class=\"entity-name-function\">onAbort</span>()",
"body": "This method is triggered when a request is ended with help of the tag <cfabort>.",
"links": [
{ "href": "http://docs.lucee.org/guides/cookbooks/application-context-basic.html", "text": "docs.lucee.org/guides/cookbooks/application-context-basic.html"},
{ "href": "https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/onabort.html", "text": "helpx.adobe.com onabort.html"}
]
},
"ondebug": {
"header": "<span class=\"entity-name-function\">onDebug()",
"body": "This method is triggered when debugging is enabled for this request</span>t.",
"header": "<span class=\"entity-name-function\">onDebug</span>()",
"body": "This method is triggered when debugging is enabled for this request.",
"links": [
{ "href": "http://docs.lucee.org/guides/cookbooks/application-context-basic.html", "text": "docs.lucee.org/guides/cookbooks/application-context-basic.html"},
{ "href": "https://helpx.adobe.com/coldfusion/cfml-reference/application-cfc-reference/ondebug.html", "text": "helpx.adobe.com ondebug.html"}
Expand Down

0 comments on commit b0bbcd3

Please sign in to comment.