This repository was archived by the owner on Sep 11, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed
UI/Components/EditorElement Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -783,6 +783,9 @@ public void ToggleComment(bool comment)
783783 var lineList = new List < DocumentLine > ( ) ;
784784 var document = editor . TextArea . Document ;
785785
786+ // Start undo transaction so undoing this doesn't result in undoing every single comment manually
787+ document . UndoStack . StartUndoGroup ( ) ;
788+
786789 // If there's no selection, add to lineList the line the caret is standing on
787790 if ( ! selectionSegments . Any ( ) )
788791 {
@@ -823,18 +826,21 @@ public void ToggleComment(bool comment)
823826 {
824827 if ( ! comment && lineText [ 0 ] == '/' && lineText [ 1 ] == '/' )
825828 {
826- editor . Document . Remove ( line . Offset + leadingWhiteSpaces , 3 ) ;
829+ editor . Document . Remove ( line . Offset + leadingWhiteSpaces , 2 ) ;
827830 }
828831 else if ( comment && lineText [ 0 ] != '/' && lineText [ 1 ] != '/' )
829832 {
830- editor . Document . Insert ( line . Offset + leadingWhiteSpaces , "// " ) ;
833+ editor . Document . Insert ( line . Offset + leadingWhiteSpaces , "//" ) ;
831834 }
832835 }
833836 else if ( comment )
834837 {
835- editor . Document . Insert ( line . Offset + leadingWhiteSpaces , "// " ) ;
838+ editor . Document . Insert ( line . Offset + leadingWhiteSpaces , "//" ) ;
836839 }
837840 }
841+
842+ // End the undo transaction
843+ document . UndoStack . EndUndoGroup ( ) ;
838844 }
839845
840846 public void ChangeCase ( bool toUpper = true )
You can’t perform that action at this time.
0 commit comments