ternjs / tern_for_sublime

Sublime Text package adding Tern support
MIT License
801 stars 52 forks source link

Need comment about src #124

Closed Alexey-T closed 8 years ago

Alexey-T commented 8 years ago

Hi. What does this block do? it finds "functions" and... What numbers 500,1500 do?

  while True:
    next = view.find("\\bfunction\\b", cur)
    if next is None or next.b > pos or (next.a == -1 and next.b == -1): 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
      start = line.a
    cur = line.b
  return sublime.Region(start, min(pos + 500, region.b))
marijnh commented 8 years ago

It decides on which range around a changed piece of code to send to the server. It prefers starting at a function boundary, and does not scan back more than 1500 characters.