Skip to content

Commit

Permalink
Merge pull request #106 from AvaloniaUI/prashantvc/issue92
Browse files Browse the repository at this point in the history
[Bug] Code suggestion in axaml is not working
  • Loading branch information
prashantvc authored Feb 9, 2024
2 parents a1986d9 + eb50ef7 commit b33fece
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/AvaloniaLSP/AvaloniaLanguageServer/Services/Buffer.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,20 @@
using System.Text;

namespace AvaloniaLanguageServer.Services;

public sealed class Buffer
{

public string? GetTextTillLine(Position position)
{
string[] lines = _text.Split(NewLine);
string[] lines = _text.Split(separator, StringSplitOptions.RemoveEmptyEntries);
var linesRange = string.Join(string.Empty, lines[0..position.Line]);
string lastLine = lines[position.Line];

string rangeText = linesRange.Replace(NewLine, string.Empty);
return rangeText + lastLine.Substring(0, position.Character);
return linesRange + lastLine.Substring(0, position.Character);
}

public string? GetLine(Position position)
{
string[] lines = _text.Split(NewLine);
string[] lines = _text.Split(separator, StringSplitOptions.RemoveEmptyEntries);
return lines[position.Line];
}

Expand All @@ -29,5 +26,5 @@ public Buffer(string text)
}

readonly string _text;
string NewLine = Environment.NewLine;
private static readonly string[] separator = ["\n", "\r\n"];
}

0 comments on commit b33fece

Please sign in to comment.