Skip to content

Commit 5bd15b1

Browse files
authored
Merge branch 'master' into PowerShell#2057
2 parents 24dbaa4 + 9e09968 commit 5bd15b1

18 files changed

+480
-261
lines changed

.github/workflows/IssuePreTriage.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Issue Pre-triage
2+
3+
on:
4+
schedule:
5+
# At 13:00 UTC every day.
6+
- cron: '0 13 * * *'
7+
# Allows you to run this workflow manually from the Actions tab
8+
workflow_dispatch:
9+
10+
defaults:
11+
run:
12+
shell: pwsh
13+
14+
env:
15+
POWERSHELL_TELEMETRY_OPTOUT: 1
16+
17+
jobs:
18+
process-new-issues:
19+
name: Process new issues
20+
timeout-minutes: 20
21+
runs-on: ubuntu-latest
22+
steps:
23+
- name: checkout
24+
uses: actions/checkout@v2
25+
26+
- name: do-work
27+
run: |
28+
$env:GITHUB_TOKEN = '${{ secrets.GITHUB_TOKEN }}'
29+
./tools/issue-mgmt/CloseDupIssues.ps1

PSReadLine/BasicEditing.cs

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,36 @@ public static void CancelLine(ConsoleKeyInfo? key = null, object arg = null)
9797
}
9898

9999
/// <summary>
100-
/// Like ForwardKillLine - deletes text from the point to the end of the line,
100+
/// Like KillLine - deletes text from the point to the end of the input,
101+
/// but does not put the deleted text in the kill ring.
102+
/// </summary>
103+
public static void ForwardDeleteInput(ConsoleKeyInfo? key = null, object arg = null)
104+
{
105+
ForwardDeleteImpl(_singleton._buffer.Length);
106+
}
107+
108+
/// <summary>
109+
/// Deletes text from the point to the end of the current logical line,
101110
/// but does not put the deleted text in the kill ring.
102111
/// </summary>
103112
public static void ForwardDeleteLine(ConsoleKeyInfo? key = null, object arg = null)
113+
{
114+
ForwardDeleteImpl(GetEndOfLogicalLinePos(_singleton._current) + 1);
115+
}
116+
117+
/// <summary>
118+
/// Deletes text from the cursor position to the specified end position
119+
/// but does not put the deleted text in the kill ring.
120+
/// </summary>
121+
/// <param name="endPosition">0-based offset to one character past the end of the text.</param>
122+
private static void ForwardDeleteImpl(int endPosition)
104123
{
105124
var current = _singleton._current;
106125
var buffer = _singleton._buffer;
107-
if (buffer.Length > 0 && current < buffer.Length)
126+
127+
if (buffer.Length > 0 && current < endPosition)
108128
{
109-
int length = buffer.Length - current;
129+
int length = endPosition - current;
110130
var str = buffer.ToString(current, length);
111131
_singleton.SaveEditItem(EditItemDelete.Create(str, current));
112132
buffer.Remove(current, length);
@@ -115,17 +135,31 @@ public static void ForwardDeleteLine(ConsoleKeyInfo? key = null, object arg = nu
115135
}
116136

117137
/// <summary>
118-
/// Like BackwardKillLine - deletes text from the point to the start of the line,
138+
/// Like BackwardKillInput - deletes text from the point to the start of the input,
139+
/// but does not put the deleted text in the kill ring.
140+
public static void BackwardDeleteInput(ConsoleKeyInfo? key = null, object arg = null)
141+
{
142+
BackwardDeleteSubstring(0, BackwardDeleteInput);
143+
}
144+
145+
/// <summary>
146+
/// Like BackwardKillLine - deletes text from the point to the start of the logical line,
119147
/// but does not put the deleted text in the kill ring.
120148
/// </summary>
121149
public static void BackwardDeleteLine(ConsoleKeyInfo? key = null, object arg = null)
122150
{
123-
if (_singleton._current > 0)
151+
var position = GetBeginningOfLinePos(_singleton._current);
152+
BackwardDeleteSubstring(position, BackwardDeleteLine);
153+
}
154+
155+
private static void BackwardDeleteSubstring(int position, Action<ConsoleKeyInfo?, object> instigator = null)
156+
{
157+
if (_singleton._current > position)
124158
{
125-
_clipboard.Record(_singleton._buffer, 0, _singleton._current);
126-
_singleton.SaveEditItem(EditItemDelete.Create(_clipboard, 0));
127-
_singleton._buffer.Remove(0, _singleton._current);
128-
_singleton._current = 0;
159+
var count = _singleton._current - position;
160+
161+
_singleton.RemoveTextToViRegister(position, count, instigator);
162+
_singleton._current = position;
129163
_singleton.Render();
130164
}
131165
}
@@ -149,15 +183,8 @@ public static void BackwardDeleteChar(ConsoleKeyInfo? key = null, object arg = n
149183
qty = Math.Min(qty, _singleton._current);
150184

151185
int startDeleteIndex = _singleton._current - qty;
152-
_singleton.SaveEditItem(
153-
EditItemDelete.Create(
154-
_singleton._buffer.ToString(startDeleteIndex, qty),
155-
startDeleteIndex,
156-
BackwardDeleteChar,
157-
arg)
158-
);
159-
_singleton.SaveToClipboard(startDeleteIndex, qty);
160-
_singleton._buffer.Remove(startDeleteIndex, qty);
186+
187+
_singleton.RemoveTextToViRegister(startDeleteIndex, qty, BackwardDeleteChar, arg);
161188
_singleton._current = startDeleteIndex;
162189
_singleton.Render();
163190
}
@@ -178,9 +205,7 @@ private void DeleteCharImpl(int qty, bool orExit)
178205
{
179206
qty = Math.Min(qty, _singleton._buffer.Length - _singleton._current);
180207

181-
SaveEditItem(EditItemDelete.Create(_buffer.ToString(_current, qty), _current, DeleteChar, qty));
182-
SaveToClipboard(_current, qty);
183-
_buffer.Remove(_current, qty);
208+
RemoveTextToViRegister(_current, qty, DeleteChar, qty);
184209
if (_current >= _buffer.Length)
185210
{
186211
_current = Math.Max(0, _buffer.Length + ViEndOfLineFactor);

PSReadLine/KeyBindings.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ void SetDefaultWindowsBindings()
209209
{ Keys.CtrlY, MakeKeyHandler(Redo, "Redo") },
210210
{ Keys.CtrlZ, MakeKeyHandler(Undo, "Undo") },
211211
{ Keys.CtrlBackspace, MakeKeyHandler(BackwardKillWord, "BackwardKillWord") },
212-
{ Keys.CtrlHome, MakeKeyHandler(BackwardDeleteLine, "BackwardDeleteLine") },
212+
{ Keys.CtrlHome, MakeKeyHandler(BackwardDeleteInput, "BackwardDeleteInput") },
213213
{ Keys.CtrlRBracket, MakeKeyHandler(GotoBrace, "GotoBrace") },
214214
{ Keys.CtrlAltQuestion, MakeKeyHandler(ShowKeyBindings, "ShowKeyBindings") },
215215
{ Keys.AltPeriod, MakeKeyHandler(YankLastArg, "YankLastArg") },
@@ -242,7 +242,7 @@ void SetDefaultWindowsBindings()
242242
_dispatchTable.Add(Keys.CtrlSpace, MakeKeyHandler(MenuComplete, "MenuComplete"));
243243
_dispatchTable.Add(Keys.AltF7, MakeKeyHandler(ClearHistory, "ClearHistory"));
244244
_dispatchTable.Add(Keys.CtrlDelete, MakeKeyHandler(KillWord, "KillWord"));
245-
_dispatchTable.Add(Keys.CtrlEnd, MakeKeyHandler(ForwardDeleteLine, "ForwardDeleteLine"));
245+
_dispatchTable.Add(Keys.CtrlEnd, MakeKeyHandler(ForwardDeleteInput, "ForwardDeleteInput"));
246246
_dispatchTable.Add(Keys.CtrlH, MakeKeyHandler(BackwardDeleteChar,"BackwardDeleteChar"));
247247

248248
// PageUp/PageDown and CtrlPageUp/CtrlPageDown bindings are supported on Windows only because they depend on the
@@ -294,7 +294,7 @@ void SetDefaultEmacsBindings()
294294
{ Keys.CtrlR, MakeKeyHandler(ReverseSearchHistory, "ReverseSearchHistory") },
295295
{ Keys.CtrlS, MakeKeyHandler(ForwardSearchHistory, "ForwardSearchHistory") },
296296
{ Keys.CtrlT, MakeKeyHandler(SwapCharacters, "SwapCharacters") },
297-
{ Keys.CtrlU, MakeKeyHandler(BackwardKillLine, "BackwardKillLine") },
297+
{ Keys.CtrlU, MakeKeyHandler(BackwardKillInput, "BackwardKillInput") },
298298
{ Keys.CtrlX, MakeKeyHandler(Chord, "ChordFirstKey") },
299299
{ Keys.CtrlW, MakeKeyHandler(UnixWordRubout, "UnixWordRubout") },
300300
{ Keys.CtrlY, MakeKeyHandler(Yank, "Yank") },
@@ -369,7 +369,7 @@ void SetDefaultEmacsBindings()
369369
// Ctrl+X,<key> table
370370
[Keys.CtrlX] = new Dictionary<PSKeyInfo, KeyHandler>
371371
{
372-
{ Keys.Backspace, MakeKeyHandler(BackwardKillLine, "BackwardKillLine") },
372+
{ Keys.Backspace, MakeKeyHandler(BackwardKillInput, "BackwardKillInput") },
373373
{ Keys.CtrlE, MakeKeyHandler(ViEditVisually, "ViEditVisually") },
374374
{ Keys.CtrlU, MakeKeyHandler(Undo, "Undo") },
375375
{ Keys.CtrlX, MakeKeyHandler(ExchangePointAndMark, "ExchangePointAndMark") },
@@ -388,9 +388,11 @@ public static KeyHandlerGroup GetDisplayGrouping(string function)
388388
case nameof(AcceptAndGetNext):
389389
case nameof(AcceptLine):
390390
case nameof(AddLine):
391+
case nameof(BackwardDeleteInput):
391392
case nameof(BackwardDeleteChar):
392393
case nameof(BackwardDeleteLine):
393394
case nameof(BackwardDeleteWord):
395+
case nameof(BackwardKillInput):
394396
case nameof(BackwardKillLine):
395397
case nameof(BackwardKillWord):
396398
case nameof(CancelLine):
@@ -408,6 +410,7 @@ public static KeyHandlerGroup GetDisplayGrouping(string function)
408410
case nameof(DeletePreviousLines):
409411
case nameof(DeleteToEnd):
410412
case nameof(DeleteWord):
413+
case nameof(ForwardDeleteInput):
411414
case nameof(ForwardDeleteLine):
412415
case nameof(InsertLineAbove):
413416
case nameof(InsertLineBelow):

PSReadLine/KeyBindings.vi.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ private void SetDefaultViBindings()
7474
{ Keys.CtrlSpace, MakeKeyHandler(PossibleCompletions, "PossibleCompletions") },
7575
{ Keys.Tab, MakeKeyHandler(ViTabCompleteNext, "ViTabCompleteNext") },
7676
{ Keys.ShiftTab, MakeKeyHandler(ViTabCompletePrevious, "ViTabCompletePrevious") },
77-
{ Keys.CtrlU, MakeKeyHandler(BackwardDeleteLine, "BackwardDeleteLine") },
77+
{ Keys.CtrlU, MakeKeyHandler(BackwardDeleteInput, "BackwardDeleteInput") },
7878
{ Keys.CtrlV, MakeKeyHandler(Paste, "Paste") },
7979
{ Keys.CtrlC, MakeKeyHandler(CancelLine, "CancelLine") },
8080
{ Keys.CtrlL, MakeKeyHandler(ClearScreen, "ClearScreen") },
8181
{ Keys.CtrlT, MakeKeyHandler(SwapCharacters, "SwapCharacters") },
8282
{ Keys.CtrlY, MakeKeyHandler(Redo, "Redo") },
8383
{ Keys.CtrlZ, MakeKeyHandler(Undo, "Undo") },
8484
{ Keys.CtrlBackspace, MakeKeyHandler(BackwardKillWord, "BackwardKillWord") },
85-
{ Keys.CtrlEnd, MakeKeyHandler(ForwardDeleteLine, "ForwardDeleteLine") },
86-
{ Keys.CtrlHome, MakeKeyHandler(BackwardDeleteLine, "BackwardDeleteLine") },
85+
{ Keys.CtrlEnd, MakeKeyHandler(ForwardDeleteInput, "ForwardDeleteInput") },
86+
{ Keys.CtrlHome, MakeKeyHandler(BackwardDeleteInput, "BackwardDeleteInput") },
8787
{ Keys.CtrlRBracket, MakeKeyHandler(GotoBrace, "GotoBrace") },
8888
{ Keys.F3, MakeKeyHandler(CharacterSearch, "CharacterSearch") },
8989
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward,"CharacterSearchBackward") },
@@ -122,13 +122,13 @@ private void SetDefaultViBindings()
122122
{ Keys.CtrlC, MakeKeyHandler(CancelLine, "CancelLine") },
123123
{ Keys.CtrlL, MakeKeyHandler(ClearScreen, "ClearScreen") },
124124
{ Keys.CtrlT, MakeKeyHandler(SwapCharacters, "SwapCharacters") },
125-
{ Keys.CtrlU, MakeKeyHandler(BackwardDeleteLine, "BackwardDeleteLine") },
125+
{ Keys.CtrlU, MakeKeyHandler(BackwardDeleteInput, "BackwardDeleteInput") },
126126
{ Keys.CtrlW, MakeKeyHandler(BackwardDeleteWord, "BackwardDeleteWord") },
127127
{ Keys.CtrlY, MakeKeyHandler(Redo, "Redo") },
128128
{ Keys.CtrlZ, MakeKeyHandler(Undo, "Undo") },
129129
{ Keys.CtrlBackspace, MakeKeyHandler(BackwardKillWord, "BackwardKillWord") },
130-
{ Keys.CtrlEnd, MakeKeyHandler(ForwardDeleteLine, "ForwardDeleteLine") },
131-
{ Keys.CtrlHome, MakeKeyHandler(BackwardDeleteLine, "BackwardDeleteLine") },
130+
{ Keys.CtrlEnd, MakeKeyHandler(ForwardDeleteInput, "ForwardDeleteInput") },
131+
{ Keys.CtrlHome, MakeKeyHandler(BackwardDeleteInput, "BackwardDeleteInput") },
132132
{ Keys.CtrlRBracket, MakeKeyHandler(GotoBrace, "GotoBrace") },
133133
{ Keys.F3, MakeKeyHandler(CharacterSearch, "CharacterSearch") },
134134
{ Keys.ShiftF3, MakeKeyHandler(CharacterSearchBackward, "CharacterSearchBackward") },

PSReadLine/KillYank.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,21 @@ public static void KillLine(ConsoleKeyInfo? key = null, object arg = null)
117117
/// Clear the input from the start of the input to the cursor. The cleared text is placed
118118
/// in the kill ring.
119119
/// </summary>
120-
public static void BackwardKillLine(ConsoleKeyInfo? key = null, object arg = null)
120+
public static void BackwardKillInput(ConsoleKeyInfo? key = null, object arg = null)
121121
{
122122
_singleton.Kill(0, _singleton._current, true);
123123
}
124124

125+
/// <summary>
126+
/// Clear the input from the start of the current logical line to the cursor. The cleared text is placed
127+
/// in the kill ring.
128+
/// </summary>
129+
public static void BackwardKillLine(ConsoleKeyInfo? key = null, object arg = null)
130+
{
131+
var start = GetBeginningOfLinePos(_singleton._current);
132+
_singleton.Kill(start, _singleton._current, true);
133+
}
134+
125135
/// <summary>
126136
/// Clear the input from the cursor to the end of the current word. If the cursor
127137
/// is between words, the input is cleared from the cursor to the end of the next word.

PSReadLine/PSReadLineResources.Designer.cs

Lines changed: 28 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

PSReadLine/PSReadLineResources.resx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,17 @@
129129
<data name="BackwardDeleteCharDescription" xml:space="preserve">
130130
<value>Delete the character before the cursor</value>
131131
</data>
132+
<data name="BackwardDeleteInputDescription" xml:space="preserve">
133+
<value>Delete text from the cursor to the start of the input</value>
134+
</data>
132135
<data name="BackwardDeleteLineDescription" xml:space="preserve">
133-
<value>Delete text from the cursor to the start of the line</value>
136+
<value>Delete text from the cursor to the start of the current logical line</value>
137+
</data>
138+
<data name="BackwardKillInputDescription" xml:space="preserve">
139+
<value>Move the text from the cursor to the beginning of the input to the kill ring</value>
134140
</data>
135141
<data name="BackwardKillLineDescription" xml:space="preserve">
136-
<value>Move the text from the cursor to the beginning of the line to the kill ring</value>
142+
<value>Move the text from the start of the current logical line to the cursor to the kill ring</value>
137143
</data>
138144
<data name="BeginningOfHistoryDescription" xml:space="preserve">
139145
<value>Move to the first item in the history</value>
@@ -180,8 +186,11 @@
180186
<data name="ForwardCharDescription" xml:space="preserve">
181187
<value>Move the cursor forward one character</value>
182188
</data>
189+
<data name="ForwardDeleteInputDescription" xml:space="preserve">
190+
<value>Delete text from the cursor to the end of the input</value>
191+
</data>
183192
<data name="ForwardDeleteLineDescription" xml:space="preserve">
184-
<value>Delete text from the cursor to the end of the line</value>
193+
<value>Delete text from the cursor to the end of the current logical line</value>
185194
</data>
186195
<data name="ShellForwardWordDescription" xml:space="preserve">
187196
<value>Move the cursor to the beginning of the next token or end of line</value>

0 commit comments

Comments
 (0)