Skip to content

Commit a01e7d9

Browse files
committed
Merge #183: Skip whitespace in test completions
2 parents d7a1fa8 + b4093d1 commit a01e7d9

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

Package/PackageDev.sublime-settings

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,8 @@
5151
// "DRAW_NO_OUTLINE", "DRAW_SOLID_UNDERLINE", "DRAW_STIPPLED_UNDERLINE",
5252
// "DRAW_SQUIGGLY_UNDERLINE", "HIDDEN", "PERSISTENT"
5353
"syntax_test.highlight_styles": ["DRAW_NO_FILL"],
54+
55+
// Whether to skip whitespace after the previous line's test assertions when
56+
// pressing the Tab key on a new syntax test line
57+
"syntax_test.skip_whitespace": false,
5458
}

plugins_/syntaxtest_dev.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,15 +284,25 @@ def run(self, edit):
284284
# find the last test assertion column on the previous line
285285
details = listener.get_details_of_test_assertion_line(details.line_region.begin() - 1)
286286
next_col = None
287-
if not details.assertion_colrange:
287+
skip_whitespace = get_setting('syntax_test.skip_whitespace', False)
288+
if details.assertion_colrange:
289+
next_col = details.assertion_colrange[1]
290+
else:
288291
# the previous line wasn't a syntax test line, so instead
289-
# find the first non-whitespace char on the line being tested above
290-
for pos in range(details.line_region.begin(), details.line_region.end()):
292+
# start at the first position on the line. We will then
293+
# advance to the first non-whitespace char on the line.
294+
next_col = 0
295+
skip_whitespace = True
296+
297+
# find the next non-whitespace char on the line being tested above
298+
if skip_whitespace:
299+
line_region = listener.get_details_of_line_being_tested()[1]
300+
pos = line_region.begin() + next_col
301+
for pos in range(pos, line_region.end()):
291302
if view.substr(pos).strip() != '':
292303
break
293304
next_col = view.rowcol(pos)[1]
294-
else:
295-
next_col = details.assertion_colrange[1]
305+
296306
col_diff = next_col - view.rowcol(cursor.begin())[1]
297307
view.insert(edit, cursor.end(), " " * col_diff)
298308
view.run_command('packagedev_suggest_syntax_test')

0 commit comments

Comments
 (0)