Skip to content

Commit c8cf272

Browse files
committed
Resolve conflicts and unify line endings to LF
1 parent 00df761 commit c8cf272

File tree

3 files changed

+82
-102
lines changed

3 files changed

+82
-102
lines changed

PSReadLine/StringBuilderCharacterExtensions.cs

+9-9
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,15 @@ public static bool InWord(this StringBuilder buffer, int i, string wordDelimiter
3434
return Character.IsInWord(buffer[i], wordDelimiters);
3535
}
3636

37-
/// <summary>
38-
/// Returns true if the character at the specified position is
39-
/// at the end of the buffer
40-
/// </summary>
41-
/// <param name="buffer"></param>
42-
/// <param name="i"></param>
37+
/// <summary>
38+
/// Returns true if the character at the specified position is
39+
/// at the end of the buffer
40+
/// </summary>
41+
/// <param name="buffer"></param>
42+
/// <param name="i"></param>
4343
/// <returns></returns>
44-
public static bool IsAtEndOfBuffer(this StringBuilder buffer, int i)
45-
{
44+
public static bool IsAtEndOfBuffer(this StringBuilder buffer, int i)
45+
{
4646
return i >= (buffer.Length - 1);
4747
}
4848

@@ -54,7 +54,7 @@ public static bool IsAtEndOfBuffer(this StringBuilder buffer, int i)
5454
/// <param name="i"></param>
5555
/// <returns></returns>
5656
public static bool IsWhiteSpace(this StringBuilder buffer, int i)
57-
{
57+
{
5858
// Treat just beyond the end of buffer as whitespace because
5959
// it looks like whitespace to the user even though they haven't
6060
// entered a character yet.

PSReadLine/TextObjects.Vi.cs

+73-73
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ private readonly IDictionary<TextObjectOperation, IDictionary<TextObjectSpan, Ke
3737
private void ViChordDeleteTextObject(ConsoleKeyInfo? key = null, object arg = null)
3838
{
3939
_textObjectOperation = TextObjectOperation.Delete;
40-
ViChordTextObject(key, arg);
40+
ViChordTextObject(key, arg);
4141
}
4242

4343
private void ViChordTextObject(ConsoleKeyInfo? key = null, object arg = null)
@@ -46,8 +46,8 @@ private void ViChordTextObject(ConsoleKeyInfo? key = null, object arg = null)
4646
{
4747
ResetTextObjectState();
4848
throw new ArgumentNullException(nameof(key));
49-
}
50-
49+
}
50+
5151
_textObjectSpan = GetRequestedTextObjectSpan(key.Value);
5252

5353
// handle text object
@@ -62,25 +62,25 @@ private void ViChordTextObject(ConsoleKeyInfo? key = null, object arg = null)
6262
ResetTextObjectState();
6363
Ding();
6464
}
65-
}
66-
67-
private TextObjectSpan GetRequestedTextObjectSpan(ConsoleKeyInfo key)
68-
{
69-
if (key.KeyChar == 'i')
70-
{
71-
return TextObjectSpan.Inner;
65+
}
66+
67+
private TextObjectSpan GetRequestedTextObjectSpan(ConsoleKeyInfo key)
68+
{
69+
if (key.KeyChar == 'i')
70+
{
71+
return TextObjectSpan.Inner;
7272
}
73-
else if (key.KeyChar == 'a')
74-
{
73+
else if (key.KeyChar == 'a')
74+
{
7575
return TextObjectSpan.Around;
7676
}
77-
else
78-
{
79-
System.Diagnostics.Debug.Assert(false);
80-
throw new NotSupportedException();
81-
}
82-
}
83-
77+
else
78+
{
79+
System.Diagnostics.Debug.Assert(false);
80+
throw new NotSupportedException();
81+
}
82+
}
83+
8484
private static void ViHandleTextObject(ConsoleKeyInfo? key = null, object arg = null)
8585
{
8686
if (
@@ -102,63 +102,63 @@ private static void ResetTextObjectState()
102102
_singleton._textObjectSpan = TextObjectSpan.None;
103103
}
104104

105-
private static void ViDeleteInnerWord(ConsoleKeyInfo? key = null, object arg = null)
106-
{
105+
private static void ViDeleteInnerWord(ConsoleKeyInfo? key = null, object arg = null)
106+
{
107107
var delimiters = _singleton.Options.WordDelimiters;
108108

109109
if (!TryGetArgAsInt(arg, out var numericArg, 1))
110-
return;
111-
112-
if (_singleton._buffer.Length == 0)
113-
{
114-
if (numericArg > 1)
115-
{
116-
Ding();
117-
}
118-
return;
119-
}
120-
121-
// unless at the end of the buffer a single delete word should not delete backwards
122-
// so if the cursor is on an empty line, do nothing
123-
124-
if (
125-
numericArg == 1 &&
126-
_singleton._current < _singleton._buffer.Length &&
127-
_singleton._buffer.IsLogigalLineEmpty(_singleton._current)
128-
)
129-
{
130-
return;
131-
}
132-
133-
var start = _singleton._buffer.ViFindBeginningOfWordObjectBoundary(_singleton._current, delimiters);
134-
var end = _singleton._current;
135-
136-
// attempting to find a valid position for multiple words
137-
// if no valid position is found, this is a no-op
138-
139-
{
140-
while (numericArg-- > 0 && end < _singleton._buffer.Length)
141-
{
142-
end = _singleton._buffer.ViFindBeginningOfNextWordObjectBoundary(end, delimiters);
143-
}
144-
145-
// attempting to delete too many words should ding
146-
147-
if (numericArg > 0)
148-
{
149-
Ding();
150-
return;
151-
}
152-
}
153-
154-
if (end > 0 && _singleton._buffer.IsAtEndOfBuffer(end - 1) && _singleton._buffer.InWord(end - 1, delimiters))
155-
{
156-
_singleton._shouldAppend = true;
157-
}
158-
159-
_singleton.RemoveTextToClipboard(start, end - start);
160-
_singleton.AdjustCursorPosition(start);
161-
_singleton.Render();
110+
return;
111+
112+
if (_singleton._buffer.Length == 0)
113+
{
114+
if (numericArg > 1)
115+
{
116+
Ding();
117+
}
118+
return;
119+
}
120+
121+
// unless at the end of the buffer a single delete word should not delete backwards
122+
// so if the cursor is on an empty line, do nothing
123+
124+
if (
125+
numericArg == 1 &&
126+
_singleton._current < _singleton._buffer.Length &&
127+
_singleton._buffer.IsLogigalLineEmpty(_singleton._current)
128+
)
129+
{
130+
return;
131+
}
132+
133+
var start = _singleton._buffer.ViFindBeginningOfWordObjectBoundary(_singleton._current, delimiters);
134+
var end = _singleton._current;
135+
136+
// attempting to find a valid position for multiple words
137+
// if no valid position is found, this is a no-op
138+
139+
{
140+
while (numericArg-- > 0 && end < _singleton._buffer.Length)
141+
{
142+
end = _singleton._buffer.ViFindBeginningOfNextWordObjectBoundary(end, delimiters);
143+
}
144+
145+
// attempting to delete too many words should ding
146+
147+
if (numericArg > 0)
148+
{
149+
Ding();
150+
return;
151+
}
152+
}
153+
154+
if (end > 0 && _singleton._buffer.IsAtEndOfBuffer(end - 1) && _singleton._buffer.InWord(end - 1, delimiters))
155+
{
156+
_singleton._shouldAppend = true;
157+
}
158+
159+
_singleton.RemoveTextToViRegister(start, end - start);
160+
_singleton.AdjustCursorPosition(start);
161+
_singleton.Render();
162162
}
163163

164164
/// <summary>

PSReadLine/YankPaste.vi.cs

-20
Original file line numberDiff line numberDiff line change
@@ -89,26 +89,6 @@ private void RemoveTextToViRegister(int start, int count, Action<ConsoleKeyInfo?
8989
_singleton._buffer.Remove(start, count);
9090
}
9191

92-
/// <summary>
93-
/// Removes a portion of text from the buffer
94-
/// and saves it to the clipboard in order to support undo.
95-
/// </summary>
96-
/// <param name="start"></param>
97-
/// <param name="count"></param>
98-
/// <param name="instigator"></param>
99-
/// <param name="arg"></param>
100-
private void RemoveTextToClipboard(int start, int count, Action<ConsoleKeyInfo?, object> instigator = null, object arg = null)
101-
{
102-
_singleton.SaveToClipboard(start, count);
103-
_singleton.SaveEditItem(EditItemDelete.Create(
104-
_clipboard,
105-
start,
106-
instigator,
107-
arg
108-
));
109-
_singleton._buffer.Remove(start, count);
110-
}
111-
11292
/// <summary>
11393
/// Yank the entire buffer.
11494
/// </summary>

0 commit comments

Comments
 (0)