Skip to content

Commit b88865a

Browse files
committed
Fix exception for use completion when a edit group is already started.
1 parent 827cebb commit b88865a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

PSReadLine/PublicAPI.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ public static void Replace(int start, int length, string replacement, Action<Con
102102
throw new ArgumentException(PSReadLineResources.ReplacementLengthTooBig, "length");
103103
}
104104

105-
_singleton.StartEditGroup();
105+
bool useEditGroup = (_singleton._editGroupStart == -1);
106+
107+
if(useEditGroup)
108+
_singleton.StartEditGroup();
106109
var str = _singleton._buffer.ToString(start, length);
107110
_singleton.SaveEditItem(EditItemDelete.Create(str, start));
108111
_singleton._buffer.Remove(start, length);
@@ -116,7 +119,8 @@ public static void Replace(int start, int length, string replacement, Action<Con
116119
{
117120
_singleton._current = start;
118121
}
119-
_singleton.EndEditGroup(instigator, instigatorArg); // Instigator is needed for VI undo
122+
if(useEditGroup)
123+
_singleton.EndEditGroup(instigator, instigatorArg); // Instigator is needed for VI undo
120124
_singleton.Render();
121125
}
122126

0 commit comments

Comments
 (0)