Skip to content

Commit

Permalink
Make sure we don't send ridiculously large fragments to the server
Browse files Browse the repository at this point in the history
This was happening on very long lines.

Issue #121
  • Loading branch information
marijnh committed May 12, 2013
1 parent 51d24ed commit 3500e84
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion tern.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,15 @@ def buffer_fragment(view, pos):
break
if region is None: return sublime.Region(pos, pos)

cur = start = view.line(max(region.a, pos - 1000)).a
start = view.line(max(region.a, pos - 1000)).a
if start < pos - 1500: start = pos - 1500
cur = start
min_indent = 10000
while True:
next = view.find("\\bfunction\\b", cur)
if next is None or next.b > pos: break
line = view.line(next.a)
if line.a < pos - 1500: line = sublime.Region(pos - 1500, line.b)
indent = count_indentation(view.substr(line))
if indent < min_indent:
min_indent = indent
Expand Down

0 comments on commit 3500e84

Please sign in to comment.