Sublime Forum

Stop text formatting in panels

#1

Is there a way for a plugin to know if the view it’s working with is in a panel (e.g. find, replace, goto, etc)?

I’m using a plugin (WordHighlight) that dynamically creates regions in views. It works great, however, it’s causing text in panels to have black backgrounds, making it hard to view/edit that text. This plugin effectively shows the problem:

import sublime
import sublime_plugin
class HighlightTest(sublime_plugin.EventListener):
    def on_selection_modified(self, view):
        view.add_regions('myregionskey', [sublime.Region(0,view.size()/2)], 'comment')

Run that, open the search panel, and type in some search text to see the issue.

0 Likes

#2

You can query the is_widget setting, which will be true for widgets

0 Likes

#3

Great, thanks, that worked. For posterity, this is the code: view.settings.get(‘is_widget’).

This isn’t documented from what I can see - is it considered part of the “public API” of Sublime?

0 Likes