Skip to content

Commit 1907259

Browse files
committed
Fix and simplify FillAllHelper quick panel tab completion
1. fix hitting tab not inserting selected text (due to calling `hide_overlay`) 2. directly call built-in `"select"` instead of custom plugin command. 3. remove obsolete input_quickpanel module and directly track visible FillAllHelper quick panels in latex_fill_all module 4. enable `tab` key only if `setting.auto_complete_commit_on_tab` is set. Otherwise `tab` and `shift+tab` cycle through items like arrow keys.
1 parent 899155d commit 1907259

File tree

6 files changed

+28
-129
lines changed

6 files changed

+28
-129
lines changed

Default (Linux).sublime-keymap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ LaTeX Package keymap for Linux
424424

425425
{
426426
"keys": ["tab"],
427-
"command": "latextools_confirm_quickpanel",
427+
"command": "select",
428428
"context": [
429429
{ "key": "overlay_visible" },
430-
{ "key": "latextools.input_overlay_visible" },
430+
{ "key": "setting.auto_complete_commit_on_tab" },
431+
{ "key": "latextools.input_overlay_visible" }
431432
],
432433
},
433434

Default (OSX).sublime-keymap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ LaTeX Package keymap for OS X
424424

425425
{
426426
"keys": ["tab"],
427-
"command": "latextools_confirm_quickpanel",
427+
"command": "select",
428428
"context": [
429429
{ "key": "overlay_visible" },
430-
{ "key": "latextools.input_overlay_visible" },
430+
{ "key": "setting.auto_complete_commit_on_tab" },
431+
{ "key": "latextools.input_overlay_visible" }
431432
],
432433
},
433434

Default (Windows).sublime-keymap

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -424,10 +424,11 @@ LaTeX Package keymap for Linux
424424

425425
{
426426
"keys": ["tab"],
427-
"command": "latextools_confirm_quickpanel",
427+
"command": "select",
428428
"context": [
429429
{ "key": "overlay_visible" },
430-
{ "key": "latextools.input_overlay_visible" },
430+
{ "key": "setting.auto_complete_commit_on_tab" },
431+
{ "key": "latextools.input_overlay_visible" }
431432
],
432433
},
433434

latextools/latex_fill_all.py

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from .utils.logging import logger
1212
from .utils.settings import get_setting
1313
from .utils.internal_types import FillAllHelper
14-
from .utils.input_quickpanel import show_input_quick_panel
1514

1615
__all__ = [
1716
"LatexFillAllEventListener",
@@ -20,6 +19,8 @@
2019
"LatexToolsReplaceWord",
2120
]
2221

22+
VISIBLE_OVERLAYS = set()
23+
2324
def reraise(tp, value, tb=None):
2425
if value is None:
2526
value = tp()
@@ -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

latextools/utils/input_quickpanel.py

Lines changed: 0 additions & 117 deletions
This file was deleted.

plugin.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,6 @@
138138
from .latextools.toggle_settings import (
139139
LatextoolsToggleKeysCommand
140140
)
141-
from .latextools.utils.input_quickpanel import (
142-
InputQuickpanelListener,
143-
LatextoolsConfirmQuickpanelCommand
144-
)
145141

146142

147143
def _filter_func(name):

0 commit comments

Comments
 (0)