Skip to content

Commit 62af315

Browse files
committed
Merge branch 'st3'
2 parents 82d488b + a5b8c6e commit 62af315

24 files changed

+376
-509
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.sublime-settings

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -206,9 +206,9 @@
206206

207207
// Ends of the names of temporary files to be deleted
208208
"temp_files_exts": [
209-
".blg",".bbl",".aux",".log",".brf",".nlo",".out",".dvi",".ps",
210-
".lof",".toc",".fls",".fdb_latexmk",".pdfsync",".synctex.gz",
211-
".ind",".ilg",".idx"
209+
".aux", ".bbl", ".blg", ".brf", ".dvi", ".fdb_latexmk", ".fls",
210+
".glo", ".idx", ".ilg", ".ind", ".lof", ".log", ".nlo", ".out",
211+
".pdfsync", ".ps", ".synctex.gz", ".thm", ".toc", ".xdy",
212212
],
213213

214214
// Folders that are not traversed when deleting temp files
@@ -550,19 +550,17 @@
550550
// ------------------------------------------------------------------
551551

552552
// OPTION: "bibliography"
553-
// Either a single bibliography plugin to use or a list of plugins
553+
// Either a single bibliography plugin to use or a list of plugins
554554
// which will be executed in order, stopping after the first result
555-
// found
555+
// found.
556556
//
557557
// Possible values:
558558
//
559-
// "traditional" the default, regex-based bibliography
560-
// parsing
559+
// "traditional" simple regex-based bibliography parsing
561560
//
562-
// "new" a newer parser which supports more complex
563-
// formatting and additional fields, but may
564-
// be slower
565-
"bibliography": "traditional",
561+
// "new" (default) a parser which supports more
562+
// complex formatting and additional fields.
563+
"bibliography": "new",
566564

567565
// OPTION: "additional_bibliography_file"
568566
// With this setting you can add the path to one or more additional

latextools/deprecated_command.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
_setting_name = "compatibility_enable_version3_commands"
1010

1111

12-
class LatextoolsDeprecatedCommand(object):
12+
class LatextoolsDeprecatedCommand:
1313
# every subclass should overwrite this attribute
1414
new_classname = ""
1515

latextools/latex_cite_completions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,9 @@ def get_completions(self, view, prefix, line):
507507
sublime.status_message("No bib files found!")
508508
return
509509
except BibParsingError as e:
510-
traceback.print_exc()
511-
sublime.status_message("Error occurred parsing {0}. {1}.".format(e.filename, e.message))
510+
msg = "Error occurred parsing {0}. {1}.".format(e.filename, e.message)
511+
logger.error(msg)
512+
sublime.status_message(msg)
512513
return
513514

514515
if prefix:

latextools/latex_cwl_completions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def get_cwl_completions():
7777
return CWL_COMPLETIONS
7878

7979

80-
class CwlCompletions(object):
80+
class CwlCompletions:
8181
"""
8282
Completion manager that coordinates between between the event listener and
8383
the thread that does the actual parsing. It also stores the completions

latextools/latex_env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ def run(self, edit, **args):
2828
if environment:
2929
environment_region = sublime.Region(point - len(environment), point)
3030
view.erase(edit, environment_region)
31-
snippet = "\\\\begin{" + environment + "}\n$1\n\\\\end{" + environment + "}$0"
31+
snippet = "\\\\begin{" + environment + "}\n\t$0\n\\\\end{" + environment + "}"
3232
else:
33-
snippet = "\\\\begin{${1:env}}\n$2\n\\end{$1}$0"
33+
snippet = "\\\\begin{${1:env}}\n\t$0\n\\end{$1}"
3434
view.run_command("insert_snippet", {"contents": snippet})
3535
else:
3636
sublime.status_message(

latextools/latex_fill_all.py

Lines changed: 22 additions & 5 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()
@@ -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

latextools/utils/analysis.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ class FileNotAnalyzed(Exception):
131131
pass
132132

133133

134-
class Analysis(object):
134+
class Analysis:
135135

136136
def __init__(self, tex_root):
137137
self._tex_root = tex_root
@@ -159,7 +159,7 @@ def tex_base_path(self, file_path):
159159
This is usually the folder of the tex root, but can change if
160160
the import package is used.
161161
Use this instead of the tex root path to implement functions
162-
like the \input command completion.
162+
like the \\input command completion.
163163
"""
164164
file_path = os.path.normpath(file_path)
165165
try:
@@ -341,7 +341,8 @@ def get_analysis(tex_root):
341341
raise TypeError("tex_root must be a string or view")
342342

343343
result = LocalCache(tex_root).cache("analysis", partial(analyze_document, tex_root))
344-
result._freeze()
344+
if result:
345+
result._freeze()
345346
return result
346347

347348

@@ -575,7 +576,7 @@ def rowcol(pos):
575576
return rowcol
576577

577578

578-
class objectview(object):
579+
class objectview:
579580
"""
580581
Converts an dict into an object, such that every dict entry
581582
is an attribute of the object

latextools/utils/cache.py

Lines changed: 14 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def _global_cache_path():
172172

173173

174174
# marker class for invalidated result
175-
class InvalidObject(object):
175+
class InvalidObject:
176176
_HASH = hash("_LaTeXTools_InvalidObject")
177177

178178
def __eq__(self, other):
@@ -196,7 +196,7 @@ def __hash__(self):
196196
_invalid_object = InvalidObject()
197197

198198

199-
class Cache(object):
199+
class Cache:
200200
"""
201201
default cache object and definition
202202
@@ -370,7 +370,7 @@ def load(self, key=None):
370370
if key is None:
371371
for entry in os.listdir(self.cache_path):
372372
if os.path.isfile(entry):
373-
entry_name = os.path.basename[entry]
373+
entry_name = os.path.basename(entry)
374374
try:
375375
self._objects[entry_name] = self._read(entry_name)
376376
except Exception:
@@ -423,7 +423,7 @@ def save(self, key=None):
423423
del _objs[k]
424424
file_path = os.path.join(self.cache_path, key)
425425
try:
426-
os.path.remove(file_path)
426+
os.remove(file_path)
427427
except OSError:
428428
pass
429429

@@ -440,15 +440,14 @@ def save(self, key=None):
440440
shutil.rmtree(self.cache_path)
441441
except OSError as e:
442442
logger.error("error while deleting %s: %s", self.cache_path, e)
443-
traceback.print_exc()
443+
444444
elif key in _objs:
445445
if _objs[key] == _invalid_object:
446446
file_path = os.path.join(self.cache_path, key)
447447
try:
448-
os.path.remove(file_path)
448+
os.remove(file_path)
449449
except OSError as e:
450450
logger.error("error while deleting %s: %s", file_path, e)
451-
traceback.print_exc()
452451
else:
453452
os.makedirs(self.cache_path, exist_ok=True)
454453
self._write(key, _objs)
@@ -473,7 +472,6 @@ def _write(self, key, obj):
473472
pickle.dump(_obj, f, protocol=-1)
474473
except OSError as e:
475474
logger.error("error while writing to %s: %s", key, e)
476-
traceback.print_exc()
477475
raise CacheMiss()
478476

479477
def _schedule_save(self):
@@ -727,31 +725,30 @@ def _get_cache_life_span(cls):
727725
is used on every cache read
728726
"""
729727

730-
def __parse_life_span_string():
728+
def __parse_life_span_string(life_span_str):
731729
try:
732-
return int(life_span_string)
730+
return int(life_span_str)
733731
except ValueError:
734732
try:
735-
(d, h, m, s) = TIME_RE.match(life_span_string).groups()
733+
(d, h, m, s) = TIME_RE.match(life_span_str).groups()
736734
# time conversions in seconds
737735
times = [(s, 1), (m, 60), (h, 3600), (d, 86400)]
738736
# sum the converted times
739737
# if not specified (None) use 0
740738
return sum(int(t[0] or 0) * t[1] for t in times)
741739
except Exception as e:
742-
logger.error("error parsing life_span_string %s", life_span_string)
743-
traceback.print_exc()
740+
logger.error("error parsing cache.life_span: %s", life_span_str)
744741
# default 30 minutes in seconds
745742
return 1800
746743

747744
with cls._LIFE_SPAN_LOCK:
748-
life_span_string = get_setting("cache.life_span")
745+
life_span_str = get_setting("cache.life_span")
749746
try:
750-
if cls._PREV_LIFE_SPAN_STR == life_span_string:
747+
if cls._PREV_LIFE_SPAN_STR == life_span_str:
751748
return cls._PREV_LIFE_SPAN
752749
except AttributeError:
753750
pass
754751

755-
cls._PREV_LIFE_SPAN_STR = life_span_string
756-
cls._PREV_LIFE_SPAN = life_span = __parse_life_span_string()
752+
cls._PREV_LIFE_SPAN_STR = life_span_str
753+
cls._PREV_LIFE_SPAN = life_span = __parse_life_span_string(life_span_str)
757754
return life_span

0 commit comments

Comments
 (0)