Skip to content

Commit

Permalink
Work around some issues with VS '>' overtype
Browse files Browse the repository at this point in the history
  • Loading branch information
mhutch committed Jul 11, 2023
1 parent 5b61fd1 commit d45937c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Editor/Commands/AutoClosingTagCommandHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,17 @@ 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));

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

if (completionSession != null) {
var trigger = new CompletionTrigger (
Expand Down

0 comments on commit d45937c

Please sign in to comment.