mirror of
https://github.com/dense-analysis/ale.git
synced 2025-12-17 17:55:56 +08:00
improve the lsp diagnostic message format (#2425)
This commit is contained in:
@@ -28,7 +28,7 @@ function! ale#lsp#response#ReadDiagnostics(response) abort
|
|||||||
for l:diagnostic in a:response.params.diagnostics
|
for l:diagnostic in a:response.params.diagnostics
|
||||||
let l:severity = get(l:diagnostic, 'severity', 0)
|
let l:severity = get(l:diagnostic, 'severity', 0)
|
||||||
let l:loclist_item = {
|
let l:loclist_item = {
|
||||||
\ 'text': l:diagnostic.message,
|
\ 'text': substitute(l:diagnostic.message, '\(\r\n\|\n\|\r\)', ' ', 'g'),
|
||||||
\ 'type': 'E',
|
\ 'type': 'E',
|
||||||
\ 'lnum': l:diagnostic.range.start.line + 1,
|
\ 'lnum': l:diagnostic.range.start.line + 1,
|
||||||
\ 'col': l:diagnostic.range.start.character + 1,
|
\ 'col': l:diagnostic.range.start.character + 1,
|
||||||
|
|||||||
@@ -109,6 +109,26 @@ Execute(ale#lsp#response#ReadDiagnostics() should include sources in detail):
|
|||||||
\ }
|
\ }
|
||||||
\ ]}})
|
\ ]}})
|
||||||
|
|
||||||
|
Execute(ale#lsp#response#ReadDiagnostics() should keep detail with line breaks but replace with spaces in text):
|
||||||
|
AssertEqual [
|
||||||
|
\ {
|
||||||
|
\ 'type': 'E',
|
||||||
|
\ 'text': 'cannot borrow `cap` as mutable more than once at a time mutable borrow starts here in previous iteration of loop',
|
||||||
|
\ 'detail': "[rustc] cannot borrow `cap` as mutable\r\nmore than once at a time\n\nmutable borrow starts here\rin previous iteration of loop",
|
||||||
|
\ 'lnum': 10,
|
||||||
|
\ 'col': 15,
|
||||||
|
\ 'end_lnum': 12,
|
||||||
|
\ 'end_col': 22,
|
||||||
|
\ }
|
||||||
|
\ ],
|
||||||
|
\ ale#lsp#response#ReadDiagnostics({'params': {'uri': 'filename.ts', 'diagnostics': [
|
||||||
|
\ {
|
||||||
|
\ 'range': Range(9, 14, 11, 22),
|
||||||
|
\ 'message': "cannot borrow `cap` as mutable\r\nmore than once at a time\n\nmutable borrow starts here\rin previous iteration of loop",
|
||||||
|
\ 'source': 'rustc',
|
||||||
|
\ }
|
||||||
|
\ ]}})
|
||||||
|
|
||||||
Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningless code):
|
Execute(ale#lsp#response#ReadDiagnostics() should consider -1 to be a meaningless code):
|
||||||
AssertEqual [
|
AssertEqual [
|
||||||
\ {
|
\ {
|
||||||
|
|||||||
Reference in New Issue
Block a user