Skip to content

Commit 8540f4f

Browse files
TysonAndreautozimu
authored andcommitted
Don't highlight if range end is character 0
This is helpful for ranges such as `{start:{line:5,character:0},end:{line:6,character:0}}` One reason a language server may use that type of range is because it doesn't guarantee that it will keep the file contents in memory, and doesn't track columns. I do this in https://github.com/tysonandre/languageserver-phan-neovim If I set up `highlight link ALEWarning todo` (etc): - With this patch, the background of the characters in line 5 are highlighted, as I'd expect. - Without this patch, the whole line 5 is highlighted, plus the first character of line 6. I'd only expect highlights in line 6 for `end:{line:6,character:1}`
1 parent c851073 commit 8540f4f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/language_server_protocol.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -624,7 +624,11 @@ impl LanguageClient {
624624
let endLine =
625625
vec![dn.range.end.line + 1, 1, dn.range.end.character + 1];
626626
middleLines.push(startLine);
627-
middleLines.push(endLine);
627+
// For a multi-ringe range ending at the exact start of the last line,
628+
// don't highlight the first character of the last line.
629+
if dn.range.end.character > 0 {
630+
middleLines.push(endLine);
631+
}
628632
middleLines
629633
}
630634
})

0 commit comments

Comments
 (0)