summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2020-08-18 01:48:07 +0100
committerw0rp <devw0rp@gmail.com>2020-08-18 01:48:07 +0100
commit4df352eee585cf50edb208aea713fe1a67ac4094 (patch)
tree32906a5c520fc9389110e2fdb93fe67c4ae7e90c
parentbc6304bdb0361b3236222cf857427a924c9e2c4d (diff)
downloadale-4df352eee585cf50edb208aea713fe1a67ac4094.zip
Fix #3294 - Fix hover off by 1, handle LSP server crashes
-rw-r--r--autoload/ale/hover.vim5
-rw-r--r--autoload/ale/lsp.vim4
-rw-r--r--test/lsp/test_lsp_startup.vader10
3 files changed, 18 insertions, 1 deletions
diff --git a/autoload/ale/hover.vim b/autoload/ale/hover.vim
index 168ff424..38b4b866 100644
--- a/autoload/ale/hover.vim
+++ b/autoload/ale/hover.vim
@@ -264,7 +264,10 @@ function! s:OnReady(line, column, opt, linter, lsp_details) abort
" hover position probably won't make sense.
call ale#lsp#NotifyForChanges(l:id, l:buffer)
- let l:column = min([a:column, len(getbufline(l:buffer, a:line)[0])])
+ let l:column = max([
+ \ min([a:column, len(getbufline(l:buffer, a:line)[0])]),
+ \ 1,
+ \])
let l:message = ale#lsp#message#Hover(l:buffer, a:line, l:column)
endif
diff --git a/autoload/ale/lsp.vim b/autoload/ale/lsp.vim
index ae8fd51d..7d99e9d2 100644
--- a/autoload/ale/lsp.vim
+++ b/autoload/ale/lsp.vim
@@ -64,6 +64,9 @@ endfunction
" Used only in tests.
function! ale#lsp#GetConnections() abort
+ " This command will throw from the sandbox.
+ let &l:equalprg=&l:equalprg
+
return s:connections
endfunction
@@ -449,6 +452,7 @@ function! ale#lsp#StartProgram(conn_id, executable, command) abort
endif
if l:started && !l:conn.is_tsserver
+ let l:conn.initialized = 0
call s:SendInitMessage(l:conn)
endif
diff --git a/test/lsp/test_lsp_startup.vader b/test/lsp/test_lsp_startup.vader
index c29690bf..cd9b59dd 100644
--- a/test/lsp/test_lsp_startup.vader
+++ b/test/lsp/test_lsp_startup.vader
@@ -422,3 +422,13 @@ Execute(Deferred addresses should be handled correctly):
Assert Start()
call ale#test#FlushJobs()
call AssertInitSuccess('foo', 'localhost:1234', 'foobar', '/foo/bar', '')
+
+Execute(Servers that have crashed should be restarted):
+ call ale#lsp#Register('foo', '/foo/bar', {})
+ call extend(ale#lsp#GetConnections()['foo:/foo/bar'], {'initialized': 1})
+
+ " Starting the program again should reset initialized to `0`.
+ call ale#lsp#StartProgram('foo:/foo/bar', 'foobar', 'foobar --start')
+
+ AssertEqual 0, ale#lsp#GetConnections()['foo:/foo/bar']['initialized']
+ AssertEqual ['initialize'], map(PopMessages(), 'v:val[''method'']')