diff --git a/PSReadLine/BasicEditing.cs b/PSReadLine/BasicEditing.cs
index 85b77bff0..5e3feb031 100644
--- a/PSReadLine/BasicEditing.cs
+++ b/PSReadLine/BasicEditing.cs
@@ -522,25 +522,17 @@ public static void InsertLineAbove(ConsoleKeyInfo? key = null, object arg = null
///
public static void InsertLineBelow(ConsoleKeyInfo? key = null, object arg = null)
{
- // Move the current position to the end of the current line and only the current line.
- if (_singleton.LineIsMultiLine())
+ int i = _singleton._current;
+ for (; i < _singleton._buffer.Length; i++)
{
- int i = _singleton._current;
- for (; i < _singleton._buffer.Length; i++)
+ if (_singleton._buffer[i] == '\n')
{
- if (_singleton._buffer[i] == '\n')
- {
- break;
- }
+ break;
}
-
- _singleton._current = i;
- }
- else
- {
- _singleton._current = _singleton._buffer.Length;
}
+ _singleton._current = i;
+
Insert('\n');
}
}
diff --git a/PSReadLine/Movement.cs b/PSReadLine/Movement.cs
index cb27c1edd..074ae4b10 100644
--- a/PSReadLine/Movement.cs
+++ b/PSReadLine/Movement.cs
@@ -21,23 +21,16 @@ public partial class PSConsoleReadLine
///
public static void EndOfLine(ConsoleKeyInfo? key = null, object arg = null)
{
- if (_singleton.LineIsMultiLine())
+ int i = _singleton._current;
+ for (; i < _singleton._buffer.Length; i++)
{
- int i = _singleton._current;
- for (; i < _singleton._buffer.Length; i++)
+ if (_singleton._buffer[i] == '\n')
{
- if (_singleton._buffer[i] == '\n')
- {
- break;
- }
+ break;
}
-
- _singleton.MoveCursor((i == _singleton._current) ? _singleton._buffer.Length : i);
- }
- else
- {
- _singleton.MoveCursor(_singleton._buffer.Length);
}
+
+ _singleton.MoveCursor((i == _singleton._current) ? _singleton._buffer.Length : i);
}
///
@@ -97,7 +90,7 @@ public static void ViForwardChar(ConsoleKeyInfo? key = null, object arg = null)
}
else
{
- ViOffsetCursorPosition(+ numericArg);
+ ViOffsetCursorPosition(+numericArg);
}
}
}
@@ -109,7 +102,7 @@ public static void ViBackwardChar(ConsoleKeyInfo? key = null, object arg = null)
{
if (TryGetArgAsInt(arg, out var numericArg, 1))
{
- ViOffsetCursorPosition(- numericArg);
+ ViOffsetCursorPosition(-numericArg);
}
}
@@ -225,7 +218,8 @@ private void MoveToLineImpl(int lineOffset)
point = point ?? ConvertOffsetToPoint(_current);
int newY = point.Value.Y + lineOffset;
- Point newPoint = new Point() {
+ Point newPoint = new Point()
+ {
X = _moveToLineDesiredColumn,
Y = Math.Max(newY, _initialY)
};
@@ -470,18 +464,18 @@ public static void GotoBrace(ConsoleKeyInfo? key = null, object arg = null)
int direction;
switch (token.Kind)
{
- case TokenKind.LParen: toMatch = TokenKind.RParen; direction = 1; break;
- case TokenKind.LCurly: toMatch = TokenKind.RCurly; direction = 1; break;
- case TokenKind.LBracket: toMatch = TokenKind.RBracket; direction = 1; break;
+ case TokenKind.LParen: toMatch = TokenKind.RParen; direction = 1; break;
+ case TokenKind.LCurly: toMatch = TokenKind.RCurly; direction = 1; break;
+ case TokenKind.LBracket: toMatch = TokenKind.RBracket; direction = 1; break;
- case TokenKind.RParen: toMatch = TokenKind.LParen; direction = -1; break;
- case TokenKind.RCurly: toMatch = TokenKind.LCurly; direction = -1; break;
- case TokenKind.RBracket: toMatch = TokenKind.LBracket; direction = -1; break;
+ case TokenKind.RParen: toMatch = TokenKind.LParen; direction = -1; break;
+ case TokenKind.RCurly: toMatch = TokenKind.LCurly; direction = -1; break;
+ case TokenKind.RBracket: toMatch = TokenKind.LBracket; direction = -1; break;
- default:
- // Nothing to match (don't match inside strings/comments)
- Ding();
- return;
+ default:
+ // Nothing to match (don't match inside strings/comments)
+ Ding();
+ return;
}
var matchCount = 0;
diff --git a/PSReadLine/Movement.vi.cs b/PSReadLine/Movement.vi.cs
index 51d932124..d900233e6 100644
--- a/PSReadLine/Movement.vi.cs
+++ b/PSReadLine/Movement.vi.cs
@@ -159,21 +159,14 @@ public static void ViEndOfPreviousGlob(ConsoleKeyInfo? key = null, object arg =
/// Move the cursor to the end of the current logical line.
///
public static void MoveToEndOfLine(ConsoleKeyInfo? key = null, object arg = null)
- {
- if (_singleton.LineIsMultiLine())
- {
- var eol = GetEndOfLogicalLinePos(_singleton._current);
- if (eol != _singleton._current)
- {
- _singleton.MoveCursor(eol);
- }
- _singleton._moveToEndOfLineCommandCount++;
- _singleton._moveToLineDesiredColumn = int.MaxValue;
- }
- else
+ {
+ var eol = GetEndOfLogicalLinePos(_singleton._current);
+ if (eol != _singleton._current)
{
- _singleton.MoveCursor(Math.Max(0, _singleton._buffer.Length + ViEndOfLineFactor));
- }
+ _singleton.MoveCursor(eol);
+ }
+ _singleton._moveToEndOfLineCommandCount++;
+ _singleton._moveToLineDesiredColumn = int.MaxValue;
}
///
diff --git a/PSReadLine/Movement.vi.multiline.cs b/PSReadLine/Movement.vi.multiline.cs
index eda16b87d..9cf057c82 100644
--- a/PSReadLine/Movement.vi.multiline.cs
+++ b/PSReadLine/Movement.vi.multiline.cs
@@ -38,13 +38,13 @@ public void MoveToFirstLine(ConsoleKeyInfo? key = null, object arg = null)
///
public void MoveToLastLine(ConsoleKeyInfo? key = null, object arg = null)
{
- if (!LineIsMultiLine())
+ var count = GetLogicalLineCount();
+ if (count == 1)
{
Ding(key, arg);
return;
}
- var count = GetLogicalLineCount();
var currentLine = GetLogicalLineNumber();
var pos = ConvertOffsetToPoint(_singleton._current);
diff --git a/PSReadLine/ReadLine.cs b/PSReadLine/ReadLine.cs
index 4395a3791..62e7c2227 100644
--- a/PSReadLine/ReadLine.cs
+++ b/PSReadLine/ReadLine.cs
@@ -555,6 +555,7 @@ private string InputLoop()
// nor a "move to line" command. In that case, the desired column
// number will be computed from the current position on the logical line.
+ _moveToEndOfLineCommandCount = 0;
_moveToLineDesiredColumn = -1;
}
}