SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
MIT License
436 stars 83 forks source link

Syntax Test helper not working for `<-` if not preceeded by a syntax test assertion line #224

Closed keith-hall closed 5 years ago

keith-hall commented 5 years ago

A traceback occurs when typing - following a syntax test token and <, if there are no syntax test assertions on the line above:

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 1082, in run_
    return self.run(edit, **args)
  File "C:\Users\keith\AppData\Roaming\Sublime Text 3\Packages\PackageDev\plugins_\syntaxtest_dev.py", line 355, in run
    col_start, col_end = lines[0].assertion_colrange
IndexError: list index out of range

i.e.

  1. open Packages/Python/tests/syntax_test_python.py
  2. place the caret at EOF
  3. type blah Enter so that there is a line without a syntax test assertion on it
  4. type # <-
  5. notice that it doesn't autocomplete the scope selector
  6. open the ST console
  7. see the traceback

the problem likely lies here, where it removes the first line from the list: https://github.com/SublimeText/PackageDev/blob/c42fd54b63fdb9ed638887aced945415cc4c5247/plugins_/syntaxtest_dev.py#L350-L353

to prove it, you can then press End (so that the - isn't selected), press Enter and type #<- again, and this time it works.