WordHighlight icon indicating copy to clipboard operation
WordHighlight copied to clipboard

Global 'Word Highlight: Disable/Enable' raises TypeError: updateEnabled() got an unexpected keyword argument 'forceUpdate'

Open dpc00 opened this issue 2 months ago • 1 comments

The global "Word Highlight: Disable / Enable" command (set_word_highlight_enabled) raises a TypeError every time it is run, so the highlights in the current view aren't updated (they stay drawn after "Disable" until the next selection change).

def updateEnabled(view):                          # takes only `view`
    ...

class SetWordHighlightEnabledCommand(sublime_plugin.ApplicationCommand):
    def run(self):
        Pref.enabled = not Pref.enabled
        updateEnabled(sublime.active_window().active_view(), forceUpdate=True)     # <- unexpected keyword

Checked in Sublime Text 4200 (Windows 11) by running the repo's own SetWordHighlightEnabledCommand (HEAD, loaded from a temp copy, Pref replaced by an object with enabled = True):

signature: updateEnabled ('view',)
EXC TypeError: updateEnabled() got an unexpected keyword argument 'forceUpdate'
Pref.enabled after the failed run: False        # the flag flipped, then the exception

(The per-view toggle ToggleWordHighlightInViewCommand calls updateEnabled(self.view) correctly, so only the global command is affected.)

Fix: drop the keyword: updateEnabled(sublime.active_window().active_view()). (updateEnabled already forces the update via highlight_occurences(view, forceUpdate=True).)

Found while testing packages from the Package Control catalog.

dpc00 avatar Sep 26 '26 03:09 dpc00

Confirmed in a live Sublime Text build 4215 (Windows 11, portable copy, repo HEAD): running sublime.run_command('set_word_highlight_enabled') prints TypeError: updateEnabled() got an unexpected keyword argument 'forceUpdate'. In the same run the rest of the highlighting works (selecting the first foo highlights all 4 exact-case matches and select_highlighted_words selects them).

dpc00 avatar Sep 26 '26 03:09 dpc00