mirror of
https://github.com/vim/vim.git
synced 2025-10-01 04:54:07 -04:00
patch 9.1.0535: newline escape wrong in ex mode
Problem: newline escape wrong in ex mode (Konrad Schwarz) Solution: partly revert patch 7.3.014, remove backslash in front of a newline when not in prompt mode in ex line mode (Mohamed Akram) This fixes newline escaping to allow passing multiple commands to ":global", multiple lines to shell commands, and ending lines in append mode with backslashes. This should fix a POSIX/(traditional) VI incompatiblity. This reverts a previous incorrect attempt at patch v7.3.014 to fix append mode which removed half of trailing backslashes which lead to, eg. the following two commands being parsed as having a different number of backslashes: ``` !echo foo\\\ ``` ``` !echo foo\\ \ ``` fixes: #6135 fixes: #7244 closes: #15120 Signed-off-by: Mohamed Akram <mohd.akram@outlook.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
committed by
Christian Brabandt
parent
84ca1388d8
commit
f3daa4525b
@@ -3138,31 +3138,15 @@ redraw:
|
||||
windgoto(msg_row, msg_col);
|
||||
pend = (char_u *)(line_ga.ga_data) + line_ga.ga_len;
|
||||
|
||||
// We are done when a NL is entered, but not when it comes after an
|
||||
// odd number of backslashes, that results in a NUL.
|
||||
if (line_ga.ga_len > 0 && pend[-1] == '\n')
|
||||
// We are done when a NL is entered, but not when it comes after a
|
||||
// backslash in prompt mode.
|
||||
if (line_ga.ga_len > 0 && pend[-1] == '\n'
|
||||
&& (line_ga.ga_len <= 1 || pend[-2] != '\\' || !promptc))
|
||||
{
|
||||
int bcount = 0;
|
||||
|
||||
while (line_ga.ga_len - 2 >= bcount && pend[-2 - bcount] == '\\')
|
||||
++bcount;
|
||||
|
||||
if (bcount > 0)
|
||||
{
|
||||
// Halve the number of backslashes: "\NL" -> "NUL", "\\NL" ->
|
||||
// "\NL", etc.
|
||||
line_ga.ga_len -= (bcount + 1) / 2;
|
||||
pend -= (bcount + 1) / 2;
|
||||
pend[-1] = '\n';
|
||||
}
|
||||
|
||||
if ((bcount & 1) == 0)
|
||||
{
|
||||
--line_ga.ga_len;
|
||||
--pend;
|
||||
*pend = NUL;
|
||||
break;
|
||||
}
|
||||
--line_ga.ga_len;
|
||||
--pend;
|
||||
*pend = NUL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user