Add finer-grained node searching by location
Add finer-grained node searching by location

Our analysis code implements facilities that allow you to identify in
which node in the AST your cursor currently lies. Unfortunately, when
the document currently doesn't parse, we rely on a "stale" version of
the AST to do this search. This is particularly problematic if we the
new document has a line that is longer than the corresponding line in
the "stale" document, as the cursor can exist outside the range of any
known node from the stale parse.

This commit will special case when we are looking at nodes on the same
line as the cursor; in the vast majority of cases, it is likely that any
node on the same line will capture most of the information a user would
expect, and therefore that is better than nothing.

In addition, it will attempt to get "close" to the cursor by selecting
the node on the line whose beginning is closest. This is obviously not
perfect (consider the case when a cursor is closer to the end of a
node's range than the beginning, in which case we will incorrectly
report the next node as the closest node), but it's already a vast
improvement, and is simple enough to fit our risk portfolio for this
(very tight) release.

heptio/vscode-jsonnet,heptio/vscode-jsonnet