Skip to content
This repository was archived by the owner on Oct 16, 2020. It is now read-only.

Commit 095b914

Browse files
committed
Merge pull request #411 from AaronLenoir/commentToggle
Fixes #105: Toggling multiple block comments
2 parents 3e5b969 + 1b4e816 commit 095b914

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

src/Main/Base/Project/Src/Editor/IFormattingStrategy.cs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,21 @@ protected void SurroundSelectionWithBlockComment(ITextEditor editor, string bloc
143143
BlockCommentRegion region = FindSelectedCommentRegion(editor, blockStart, blockEnd);
144144

145145
if (region != null) {
146-
editor.Document.Remove(region.EndOffset, region.CommentEnd.Length);
147-
editor.Document.Remove(region.StartOffset, region.CommentStart.Length);
146+
do {
147+
editor.Document.Remove(region.EndOffset, region.CommentEnd.Length);
148+
editor.Document.Remove(region.StartOffset, region.CommentStart.Length);
149+
150+
int selectionStart = region.EndOffset;
151+
int selectionLength = editor.SelectionLength - (region.EndOffset - editor.SelectionStart);
152+
153+
if(selectionLength > 0) {
154+
editor.Select(region.EndOffset, selectionLength);
155+
region = FindSelectedCommentRegion(editor, blockStart, blockEnd);
156+
} else {
157+
region = null;
158+
}
159+
} while(region != null);
160+
148161
} else {
149162
editor.Document.Insert(endOffset, blockEnd);
150163
editor.Document.Insert(startOffset, blockStart);

0 commit comments

Comments
 (0)