diff --git a/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs b/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs index 7d32718..7f7142c 100644 --- a/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs +++ b/src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs @@ -5,16 +5,15 @@ public sealed class Buffer public string? GetTextTillLine(Position position) { - string[] lines = _text.Split(separator, StringSplitOptions.RemoveEmptyEntries); - var linesRange = string.Join(string.Empty, lines[0..position.Line]); - string lastLine = lines[position.Line]; - - return linesRange + lastLine.Substring(0, position.Character); + string[] lines = _text.Split(separator, StringSplitOptions.None); + string text = string.Join("\n", lines[..position.Line]); + string line = lines[position.Line][..position.Character]; + return $"{text}\n{line}"; } public string? GetLine(Position position) { - string[] lines = _text.Split(separator, StringSplitOptions.RemoveEmptyEntries); + string[] lines = _text.Split(separator, StringSplitOptions.None); return lines[position.Line]; } @@ -27,4 +26,4 @@ public Buffer(string text) readonly string _text; private static readonly string[] separator = ["\n", "\r\n"]; -} \ No newline at end of file +}