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 12, 2023
1 parent 1184078 commit 63293ef
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 63293ef

Please sign in to comment.