Skip to content

Commit 7f737a1

Browse files
committed
When evaluating buffer fails, scroll to error line (closes #28)
1 parent fb1c86b commit 7f737a1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

package.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ def handle_value(msg):
229229
eval.update("success", msg.get("value"))
230230
return True
231231

232+
def set_selection(view, region):
233+
sel = view.sel()
234+
sel.clear()
235+
sel.add(region)
236+
view.show(region, show_surrounds = True, keep_to_left = True, animate = True)
237+
232238
def handle_exception(msg):
233239
if "id" in msg and msg["id"] in conn.evals:
234240
eval = conn.evals[msg["id"]]
@@ -243,6 +249,7 @@ def handle_exception(msg):
243249
column = get("column")
244250
point = eval.view.text_point_utf16(line - 1, column - 1, clamp_column = True)
245251
region = sublime.Region(point, eval.view.line(point).end())
252+
set_selection(eval.view, sublime.Region(point, point))
246253
eval.trace = get("trace")
247254
eval.update("exception", text, region)
248255
return True

0 commit comments

Comments
 (0)