Skip to content

Commit e9e2d0e

Browse files
committed
Merge branch 'master' of https://github.com/lzybkr/PSReadLine
2 parents cf0c352 + e2019fa commit e9e2d0e

File tree

5 files changed

+26
-6
lines changed

5 files changed

+26
-6
lines changed

ChocolateyPackage/PSReadline.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package>
33
<metadata>
44
<id>PSReadline</id>
5-
<version>1.0.0.10</version>
5+
<version>1.0.0.11</version>
66
<authors>Jason Shirk</authors>
77
<owners>Jason Shirk</owners>
88
<projectUrl>https://github.com/lzybkr/PSReadLine</projectUrl>

PSReadLine/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,4 @@
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
3434
[assembly: AssemblyVersion("1.0.0.0")]
35-
[assembly: AssemblyFileVersion("1.0.0.10")]
35+
[assembly: AssemblyFileVersion("1.0.0.11")]

PSReadLine/Changes.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
### Version 1.0.0.11
2+
3+
Bug fixes:
4+
* Fixed MenuComplete to actually work
15

26
### Version 1.0.0.10
37

PSReadLine/Completion.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
using System;
22
using System.Collections;
3+
using System.Collections.Generic;
4+
using System.Diagnostics;
35
using System.Diagnostics.CodeAnalysis;
46
using System.Linq;
57
using System.Management.Automation;
@@ -415,7 +417,7 @@ private void PossibleCompletionsImpl(CommandCompletion completions, bool menuSel
415417

416418
if (menuSelect)
417419
{
418-
StartEditGroup();
420+
var undoPoint = _edits.Count;
419421

420422
int selectedItem = 0;
421423
bool undo = false;
@@ -502,12 +504,26 @@ private void PossibleCompletionsImpl(CommandCompletion completions, bool menuSel
502504

503505
WriteBlankLines(displayRows, menuAreaTop);
504506

505-
EndEditGroup();
507+
var lastInsert = ((GroupedEdit)_edits[_edits.Count - 1])._groupedEditItems[1];
508+
Debug.Assert(lastInsert is EditItemInsertString, "The only edits possible here are pairs of Delete/Insert");
509+
var firstDelete = ((GroupedEdit)_edits[undoPoint])._groupedEditItems[0];
510+
Debug.Assert(firstDelete is EditItemDelete, "The only edits possible here are pairs of Delete/Insert");
511+
512+
var groupEditCount = _edits.Count - undoPoint;
513+
_edits.RemoveRange(undoPoint, groupEditCount);
514+
_undoEditIndex = undoPoint;
506515

507516
if (undo)
508517
{
509518
// Pretend it never happened.
510-
Undo();
519+
lastInsert.Undo();
520+
firstDelete.Undo();
521+
Render();
522+
}
523+
else
524+
{
525+
// Leave one edit instead of possibly many to undo
526+
SaveEditItem(GroupedEdit.Create(new List<EditItem> { firstDelete, lastInsert }));
511527
}
512528
}
513529
else

PSReadLine/UndoRedo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public override void Redo()
175175

176176
class GroupedEdit : EditItem
177177
{
178-
private List<EditItem> _groupedEditItems;
178+
internal List<EditItem> _groupedEditItems;
179179

180180
public static EditItem Create(List<EditItem> groupedEditItems)
181181
{

0 commit comments

Comments
 (0)