Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spine parser recovery and work around overtype issue #73

Merged
merged 2 commits into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Editor/Commands/AutoClosingTagCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,19 @@ void InsertCloseTag (TypeCharCommandArgs args, CommandExecutionContext execution
}

var bufferEdit = args.SubjectBuffer.CreateEdit ();

// if there's an extra > after committing due to VS losing track of overtype, delete it
ITextSnapshot snapshot = args.SubjectBuffer.CurrentSnapshot;
if (snapshot.Length > position && snapshot[position] == '>') {
bufferEdit.Delete (new Span (position, 1));
}

bufferEdit.Insert (position, $"</{el.Name.FullName}>");

bufferEdit.Apply ();
args.TextView.Caret.MoveTo (new SnapshotPoint (args.SubjectBuffer.CurrentSnapshot, position));
snapshot = args.SubjectBuffer.CurrentSnapshot;

args.TextView.Caret.MoveTo (new SnapshotPoint (snapshot, position));

if (completionSession != null) {
var trigger = new CompletionTrigger (
Expand Down
2 changes: 1 addition & 1 deletion Editor/Parsing/XmlBackgroundParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static int MaximumCompatiblePosition (ITextSnapshot snapshotA, ITextSnapshot sna
while (newVersion.VersionNumber != oldVersion.VersionNumber) {
if (oldVersion.Changes != null) {
foreach (var change in oldVersion.Changes) {
if (change.OldPosition > position) {
if (change.OldPosition < position) {
position = change.OldPosition;
break;
}
Expand Down
Loading