1111from .utils .logging import logger
1212from .utils .settings import get_setting
1313from .utils .internal_types import FillAllHelper
14- from .utils .input_quickpanel import show_input_quick_panel
1514
1615__all__ = [
1716 "LatexFillAllEventListener" ,
2019 "LatexToolsReplaceWord" ,
2120]
2221
22+ VISIBLE_OVERLAYS = set ()
23+
2324def reraise (tp , value , tb = None ):
2425 if value is None :
2526 value = tp ()
@@ -28,7 +29,7 @@ def reraise(tp, value, tb=None):
2829 raise value
2930
3031
31- class LatexFillHelper ( object ) :
32+ class LatexFillHelper :
3233 """
3334 Base class for some LaTeXTools TextCommands. Implements several methods
3435 helpful for inserting text into the view and updating the cursor posiiton.
@@ -65,7 +66,7 @@ def complete_auto_match(self, view, edit, insert_char):
6566 :param insert_char:
6667 the character to try to automatch
6768 """
68- if sublime . load_settings ( "Preferences.sublime- settings" ).get ("auto_match_enabled" , True ):
69+ if view . settings ( ).get ("auto_match_enabled" , True ):
6970 # simple case: we have an insert char, insert closing char,
7071 # if its defined
7172 if insert_char :
@@ -569,7 +570,7 @@ def match_selector(self, view, selector):
569570 return all (view .match_selector (sel .b , selector ) for sel in view .sel ())
570571
571572
572- class LatexFillAllPluginConsumer ( object ) :
573+ class LatexFillAllPluginConsumer :
573574 """
574575 Base class for classes which use FillAllHelper plugins
575576 """
@@ -628,6 +629,14 @@ def on_query_context(self, view, key, operator, operand, match_all):
628629 key is "lt_fill_all_{name}" where name is the short name of the
629630 completion type, e.g. "lt_fill_all_cite", etc.
630631 """
632+
633+ # autofill input quick panel visible
634+ if key == "latextools.input_overlay_visible" :
635+ try :
636+ return view .window ().id () in VISIBLE_OVERLAYS
637+ except :
638+ return False
639+
631640 # quick exit conditions
632641 if not key .startswith ("lt_fill_all_" ):
633642 return None
@@ -991,8 +1000,13 @@ def run(self, edit, completion_type=None, insert_char="", overwrite=False, force
9911000 self .remove_regions (view , edit , remove_regions )
9921001 self .clear_bracket_cache ()
9931002 else :
1003+ window = view .window ()
1004+ if not window :
1005+ self .clear_bracket_cache ()
1006+ return
9941007
9951008 def on_done (i , text = "" ):
1009+ VISIBLE_OVERLAYS .discard (window .id ())
9961010 if i is None :
9971011 insert_text = text
9981012 elif i < 0 :
@@ -1019,7 +1033,10 @@ def on_done(i, text=""):
10191033 },
10201034 )
10211035
1022- show_input_quick_panel (view .window (), formatted_completions , on_done )
1036+ # track visible input quick panels to provide key binding context
1037+ VISIBLE_OVERLAYS .add (window .id ())
1038+ window .show_quick_panel (formatted_completions , on_done )
1039+
10231040 self .clear_bracket_cache ()
10241041
10251042
0 commit comments