ternjs / tern_for_vim

Tern plugin for Vim
MIT License
1.83k stars 100 forks source link

:TernDef doesn't work with files over 250 lines #116

Closed Rantanen closed 9 years ago

Rantanen commented 9 years ago

Rantanen/node-mumble/lib/MumbleConnection.js#L69

Cursor on line 69 on top of _waitForPrefix. :TernDef gives no definition found. If the file is cut shorter below 250 lines :TernDef works just fine.

250 lines seems to be the limit for whether tern_for_vim sends the request with partial or full file content. The partial requests seem to fail at least for most cases where you're looking up function definitions.

The Emacs integration doesn't have the same issue.

Rantanen commented 9 years ago

I've got two fixes for this.

Now these two solutions are not mutually exclusive. What I'm curious about is the 250 line limit for partial vs full request. I just removed the limit locally and tested this with a 18 000 lines long file. The results took around 2 seconds independent of whether the full file content was sent in the request or if tern could read it from the disk.

So I would suggest both of these changes:

Do note this applies only to functionality such as :TernDef that is invoked by the user specifically. In this case getting results is way more important than performance considerations.

Docs and completions are different from this. Auto-complete is meant to assist the user and if that takes seconds, it gets in the way - especially in a synchronous environment, which I believe Vim is.

marijnh commented 9 years ago

The bug was that file fragments were enabled at all in a definition query. That does not work, since you need an up-to-date view of the file to correctly locate a definition. Attached patch fixes this. Does it solve your issue?

Rantanen commented 9 years ago

The patch fixes this. Thanks!