Skip to content

Commit

Permalink
Don't try to read unreadable buffer
Browse files Browse the repository at this point in the history
bufnr() can return a result for recently read files which are not loaded
in the current session. When this happens getbufline() will fail. Gate
the read with bufloaded.
  • Loading branch information
natebosch committed May 31, 2017
1 parent ca86d8b commit ca26cf6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
- Sort diagnostics in location list.
- Allow only 1 server command per filetype.
- Add commands for GoToDefinition and FindReferences
- Bug fix: Don't try to read lines from unreadable buffer.

# 0.1.3

Expand Down
6 changes: 3 additions & 3 deletions autoload/lsc/reference.vim
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ function! s:QuickFixItem(location) abort
let file_path = lsc#util#documentPath(a:location.uri)
let item.filename = fnamemodify(file_path, ':~:.')
let bufnr = bufnr(file_path)
if bufnr == -1
let item.text = readfile(file_path, '', item.lnum)[item.lnum - 1]
else
if bufnr != -1 && bufloaded(bufnr)
let item.text = getbufline(bufnr, item.lnum)[0]
else
let item.text = readfile(file_path, '', item.lnum)[item.lnum - 1]
endif
return item
endfunction
Expand Down

0 comments on commit ca26cf6

Please sign in to comment.