mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-11 15:01:57 +08:00
Fix ale#util#GetBufferContents and propagate use (#4457)
* Use newline characters instead in ale#util#GetBufferContents * Propagate use of ale#util#GetBufferContents * Add ale#util#GetContentBuffer test
This commit is contained in:
committed by
GitHub
parent
011e4f6590
commit
e1a0781f9d
@@ -52,28 +52,24 @@ function! ale#lsp#message#Exit() abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#lsp#message#DidOpen(buffer, language_id) abort
|
function! ale#lsp#message#DidOpen(buffer, language_id) abort
|
||||||
let l:lines = getbufline(a:buffer, 1, '$')
|
|
||||||
|
|
||||||
return [1, 'textDocument/didOpen', {
|
return [1, 'textDocument/didOpen', {
|
||||||
\ 'textDocument': {
|
\ 'textDocument': {
|
||||||
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
|
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
|
||||||
\ 'languageId': a:language_id,
|
\ 'languageId': a:language_id,
|
||||||
\ 'version': ale#lsp#message#GetNextVersionID(),
|
\ 'version': ale#lsp#message#GetNextVersionID(),
|
||||||
\ 'text': join(l:lines, "\n") . "\n",
|
\ 'text': ale#util#GetBufferContents(a:buffer),
|
||||||
\ },
|
\ },
|
||||||
\}]
|
\}]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#lsp#message#DidChange(buffer) abort
|
function! ale#lsp#message#DidChange(buffer) abort
|
||||||
let l:lines = getbufline(a:buffer, 1, '$')
|
|
||||||
|
|
||||||
" For changes, we simply send the full text of the document to the server.
|
" For changes, we simply send the full text of the document to the server.
|
||||||
return [1, 'textDocument/didChange', {
|
return [1, 'textDocument/didChange', {
|
||||||
\ 'textDocument': {
|
\ 'textDocument': {
|
||||||
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
|
\ 'uri': ale#util#ToURI(expand('#' . a:buffer . ':p')),
|
||||||
\ 'version': ale#lsp#message#GetNextVersionID(),
|
\ 'version': ale#lsp#message#GetNextVersionID(),
|
||||||
\ },
|
\ },
|
||||||
\ 'contentChanges': [{'text': join(l:lines, "\n") . "\n"}]
|
\ 'contentChanges': [{'text': ale#util#GetBufferContents(a:buffer)}]
|
||||||
\}]
|
\}]
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
@@ -542,7 +542,7 @@ function! ale#util#SetBufferContents(buffer, lines) abort
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#util#GetBufferContents(buffer) abort
|
function! ale#util#GetBufferContents(buffer) abort
|
||||||
return join(getbufline(a:buffer, 1, '$'), '\n') . '\n'
|
return join(getbufline(a:buffer, 1, '$'), "\n") . "\n"
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! ale#util#ToURI(resource) abort
|
function! ale#util#ToURI(resource) abort
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ Given typescript(A TypeScript file with 3 lines):
|
|||||||
bar()
|
bar()
|
||||||
baz()
|
baz()
|
||||||
|
|
||||||
|
Execute(ale#util#GetBufferContents() should return correctly formatted newlines):
|
||||||
|
AssertEqual "foo()\nbar()\nbaz()\n", ale#util#GetBufferContents(bufnr(''))
|
||||||
|
|
||||||
Execute(ale#lsp#message#DidOpen() should return correct messages):
|
Execute(ale#lsp#message#DidOpen() should return correct messages):
|
||||||
let g:ale_lsp_next_version_id = 12
|
let g:ale_lsp_next_version_id = 12
|
||||||
AssertEqual
|
AssertEqual
|
||||||
|
|||||||
Reference in New Issue
Block a user