Home Download Buy Blog Forum Support

Dynamic highlighting

Dynamic highlighting

Postby jburnett on Sun Feb 10, 2013 8:53 pm

What would be the recommended way of highlighting parts of a view as the selection changes? I've been fiddling with updating the WordHighlight plugin, and have the moral equivalent of the following:

Code: Select all
import sublime_plugin

class HighlightCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        pass

class TestListener(sublime_plugin.EventListener):
    def on_selection_modified(self, view):
        view.run_command('highlight')

...however, this seems to throw a wrench into undo grouping somehow, in that while this plugin is active each character inserted becomes its own undo entry.
jburnett
 
Posts: 89
Joined: Wed Jul 27, 2011 9:23 pm

Re: Dynamic highlighting

Postby jburnett on Sun Mar 24, 2013 10:33 pm

Thought I'd re-ping on this, and see if there was any official guidance here?
jburnett
 
Posts: 89
Joined: Wed Jul 27, 2011 9:23 pm

Re: Dynamic highlighting

Postby adzenith on Mon Mar 25, 2013 8:39 pm

It's probably because "HighlightCommand" is a TextCommand, and thus gets its own edit object (you can see it there in the definition). Just have a separate highlight function and have both TestListener and HighlightCommand call it.
Seems like empty edits should be ignored, but I guess they're not being.
adzenith
 
Posts: 1214
Joined: Mon Oct 19, 2009 9:12 pm

Re: Dynamic highlighting

Postby DavidLGoldberg on Fri Mar 29, 2013 5:41 pm

The only way I have found out to get around the undo problem is to open up a temporary tab on top...
DavidLGoldberg
 
Posts: 11
Joined: Sat Mar 16, 2013 2:57 pm

Re: Dynamic highlighting

Postby adzenith on Mon Apr 01, 2013 7:30 pm

Did my recommendation not work?
adzenith
 
Posts: 1214
Joined: Mon Oct 19, 2009 9:12 pm


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 7 guests