mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #2555 Remove "j" flag from 'cpoptions'
This commit is contained in:
commit
a7b5ae37a7
@ -147,8 +147,7 @@ These commands, except "gJ", insert one space in place of the <EOL> unless
|
|||||||
there is trailing white space or the next line starts with a ')'. These
|
there is trailing white space or the next line starts with a ')'. These
|
||||||
commands, except "gJ", delete any leading white space on the next line. If
|
commands, except "gJ", delete any leading white space on the next line. If
|
||||||
the 'joinspaces' option is on, these commands insert two spaces after a '.',
|
the 'joinspaces' option is on, these commands insert two spaces after a '.',
|
||||||
'!' or '?' (but if 'cpoptions' includes the 'j' flag, they insert two spaces
|
'!' or '?'.
|
||||||
only after a '.').
|
|
||||||
The 'B' and 'M' flags in 'formatoptions' change the behavior for inserting
|
The 'B' and 'M' flags in 'formatoptions' change the behavior for inserting
|
||||||
spaces before and after a multi-byte character |fo-table|.
|
spaces before and after a multi-byte character |fo-table|.
|
||||||
|
|
||||||
|
@ -1779,9 +1779,6 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
*cpo-I*
|
*cpo-I*
|
||||||
I When moving the cursor up or down just after inserting
|
I When moving the cursor up or down just after inserting
|
||||||
indent for 'autoindent', do not delete the indent.
|
indent for 'autoindent', do not delete the indent.
|
||||||
*cpo-j*
|
|
||||||
j When joining lines, only add two spaces after a '.',
|
|
||||||
not after '!' or '?'. Also see 'joinspaces'.
|
|
||||||
*cpo-J*
|
*cpo-J*
|
||||||
J A |sentence| has to be followed by two spaces after
|
J A |sentence| has to be followed by two spaces after
|
||||||
the '.', '!' or '?'. A <Tab> is not recognized as
|
the '.', '!' or '?'. A <Tab> is not recognized as
|
||||||
@ -4024,7 +4021,6 @@ A jump table for the options with a short description can be found at |Q_op|.
|
|||||||
'joinspaces' 'js' boolean (default on)
|
'joinspaces' 'js' boolean (default on)
|
||||||
global
|
global
|
||||||
Insert two spaces after a '.', '?' and '!' with a join command.
|
Insert two spaces after a '.', '?' and '!' with a join command.
|
||||||
When 'cpoptions' includes the 'j' flag, only do this after a '.'.
|
|
||||||
Otherwise only one space is inserted.
|
Otherwise only one space is inserted.
|
||||||
|
|
||||||
*'key'*
|
*'key'*
|
||||||
|
@ -3719,12 +3719,11 @@ static int ins_compl_get_exp(pos_T *ini)
|
|||||||
/* IObuf =~ "\k.* ", thus len >= 2 */
|
/* IObuf =~ "\k.* ", thus len >= 2 */
|
||||||
if (p_js
|
if (p_js
|
||||||
&& (IObuff[len - 2] == '.'
|
&& (IObuff[len - 2] == '.'
|
||||||
|| (vim_strchr(p_cpo, CPO_JOINSP)
|
|| IObuff[len - 2] == '?'
|
||||||
== NULL
|
|| IObuff[len - 2] == '!')) {
|
||||||
&& (IObuff[len - 2] == '?'
|
|
||||||
|| IObuff[len - 2] == '!'))))
|
|
||||||
IObuff[len++] = ' ';
|
IObuff[len++] = ' ';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* copy as much as possible of the new word */
|
/* copy as much as possible of the new word */
|
||||||
if (tmp_ptr - ptr >= IOSIZE - len)
|
if (tmp_ptr - ptr >= IOSIZE - len)
|
||||||
tmp_ptr = ptr + IOSIZE - len - 1;
|
tmp_ptr = ptr + IOSIZE - len - 1;
|
||||||
|
@ -3460,14 +3460,12 @@ int do_join(long count,
|
|||||||
endcurr1 = endcurr2;
|
endcurr1 = endcurr2;
|
||||||
else
|
else
|
||||||
++spaces[t];
|
++spaces[t];
|
||||||
/* extra space when 'joinspaces' set and line ends in '.' */
|
// Extra space when 'joinspaces' set and line ends in '.', '?', or '!'.
|
||||||
if ( p_js
|
if (p_js && (endcurr1 == '.' || endcurr1 == '?' || endcurr1 == '!')) {
|
||||||
&& (endcurr1 == '.'
|
|
||||||
|| (vim_strchr(p_cpo, CPO_JOINSP) == NULL
|
|
||||||
&& (endcurr1 == '?' || endcurr1 == '!'))))
|
|
||||||
++spaces[t];
|
++spaces[t];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
currsize = (int)STRLEN(curr);
|
currsize = (int)STRLEN(curr);
|
||||||
sumsize += currsize + spaces[t];
|
sumsize += currsize + spaces[t];
|
||||||
endcurr1 = endcurr2 = NUL;
|
endcurr1 = endcurr2 = NUL;
|
||||||
|
@ -97,7 +97,6 @@
|
|||||||
#define CPO_FNAMEW 'F' /* set file name for ":w file" */
|
#define CPO_FNAMEW 'F' /* set file name for ":w file" */
|
||||||
#define CPO_INTMOD 'i' /* interrupt a read makes buffer modified */
|
#define CPO_INTMOD 'i' /* interrupt a read makes buffer modified */
|
||||||
#define CPO_INDENT 'I' /* remove auto-indent more often */
|
#define CPO_INDENT 'I' /* remove auto-indent more often */
|
||||||
#define CPO_JOINSP 'j' /* only use two spaces for join after '.' */
|
|
||||||
#define CPO_ENDOFSENT 'J' /* need two spaces to detect end of sentence */
|
#define CPO_ENDOFSENT 'J' /* need two spaces to detect end of sentence */
|
||||||
#define CPO_KEYCODE 'k' /* don't recognize raw key code in mappings */
|
#define CPO_KEYCODE 'k' /* don't recognize raw key code in mappings */
|
||||||
#define CPO_KOFFSET 'K' /* don't wait for key code in mappings */
|
#define CPO_KOFFSET 'K' /* don't wait for key code in mappings */
|
||||||
@ -141,9 +140,9 @@
|
|||||||
* cursor would not move */
|
* cursor would not move */
|
||||||
/* default values for Vim, Vi and POSIX */
|
/* default values for Vim, Vi and POSIX */
|
||||||
#define CPO_VIM "aABceFs"
|
#define CPO_VIM "aABceFs"
|
||||||
#define CPO_VI "aAbBcCdDeEfFiIjJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;"
|
#define CPO_VI "aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>;"
|
||||||
#define CPO_ALL \
|
#define CPO_ALL \
|
||||||
"aAbBcCdDeEfFiIjJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>#{|&/\\.;"
|
"aAbBcCdDeEfFiIJkKlLmMnoOpPqrRsStuvWxXyZ$!%+<>#{|&/\\.;"
|
||||||
|
|
||||||
/* characters for p_ww option: */
|
/* characters for p_ww option: */
|
||||||
#define WW_ALL "bshl<>[],~"
|
#define WW_ALL "bshl<>[],~"
|
||||||
|
@ -4335,11 +4335,11 @@ search_line:
|
|||||||
/* IObuf =~ "\(\k\|\i\).* ", thus i >= 2*/
|
/* IObuf =~ "\(\k\|\i\).* ", thus i >= 2*/
|
||||||
if (p_js
|
if (p_js
|
||||||
&& (IObuff[i-2] == '.'
|
&& (IObuff[i-2] == '.'
|
||||||
|| (vim_strchr(p_cpo, CPO_JOINSP) == NULL
|
|| IObuff[i-2] == '?'
|
||||||
&& (IObuff[i-2] == '?'
|
|| IObuff[i-2] == '!')) {
|
||||||
|| IObuff[i-2] == '!'))))
|
|
||||||
IObuff[i++] = ' ';
|
IObuff[i++] = ' ';
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/* copy as much as possible of the new word */
|
/* copy as much as possible of the new word */
|
||||||
if (p - aux >= IOSIZE - i)
|
if (p - aux >= IOSIZE - i)
|
||||||
p = aux + IOSIZE - i - 1;
|
p = aux + IOSIZE - i - 1;
|
||||||
|
@ -14,7 +14,7 @@ SCRIPTS := test_autoformat_join.out \
|
|||||||
test11.out test12.out test13.out test14.out \
|
test11.out test12.out test13.out test14.out \
|
||||||
test17.out \
|
test17.out \
|
||||||
test24.out \
|
test24.out \
|
||||||
test26.out test27.out test29.out test30.out \
|
test26.out test27.out test30.out \
|
||||||
test32.out test34.out \
|
test32.out test34.out \
|
||||||
test36.out test37.out test39.out test40.out \
|
test36.out test37.out test39.out test40.out \
|
||||||
test42.out test43.out test45.out \
|
test42.out test43.out test45.out \
|
||||||
|
@ -1,229 +0,0 @@
|
|||||||
Test for joining lines and marks in them
|
|
||||||
in compatible and nocompatible modes
|
|
||||||
and with 'joinspaces' set or not
|
|
||||||
and with 'cpoptions' flag 'j' set or not
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:so small.vim
|
|
||||||
:set nojoinspaces
|
|
||||||
:set cpoptions-=j
|
|
||||||
/firstline/
|
|
||||||
j"td/^STARTTEST/-1
|
|
||||||
PJjJjJjJjJjJjJjJjJjJjJjJjJjJj05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions+=j
|
|
||||||
j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions-=j joinspaces
|
|
||||||
j"tpJjJjJjJjJjJjJjJjJjJjJjJjJjJj05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpoptions+=j
|
|
||||||
j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p:set cpo+=qo
|
|
||||||
j"tpJjJjJjJjJjJjJjJjJjJjJjJjJjJj4Jy3l$pjd/STARTTEST/-2
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
firstline
|
|
||||||
asdfasdf.
|
|
||||||
asdf
|
|
||||||
asdfasdf.
|
|
||||||
asdf
|
|
||||||
asdfasdf.
|
|
||||||
asdf
|
|
||||||
asdfasdf.
|
|
||||||
asdf
|
|
||||||
asdfasdf.
|
|
||||||
asdf
|
|
||||||
asdfasdf.
|
|
||||||
asdf
|
|
||||||
asdfasdf.
|
|
||||||
asdf
|
|
||||||
asdfasdf
|
|
||||||
asdf
|
|
||||||
asdfasdf
|
|
||||||
asdf
|
|
||||||
asdfasdf
|
|
||||||
asdf
|
|
||||||
asdfasdf
|
|
||||||
asdf
|
|
||||||
asdfasdf
|
|
||||||
asdf
|
|
||||||
asdfasdf
|
|
||||||
asdf
|
|
||||||
asdfasdf
|
|
||||||
asdf
|
|
||||||
zx cvn.
|
|
||||||
as dfg?
|
|
||||||
hjkl iop!
|
|
||||||
ert
|
|
||||||
zx cvn.
|
|
||||||
as dfg?
|
|
||||||
hjkl iop!
|
|
||||||
ert
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
/^{/+1
|
|
||||||
:set comments=s1:/*,mb:*,ex:*/,://
|
|
||||||
:set nojoinspaces fo=j
|
|
||||||
:set backspace=eol,start
|
|
||||||
:.,+3join
|
|
||||||
j4J
|
|
||||||
:.,+2join
|
|
||||||
j3J
|
|
||||||
:.,+2join
|
|
||||||
j3J
|
|
||||||
:.,+2join
|
|
||||||
jj3J
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the previous comment leader is not removed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the previous comment leader is not removed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Should the next comment leader be left alone?
|
|
||||||
// Yes.
|
|
||||||
|
|
||||||
// Should the next comment leader be left alone?
|
|
||||||
// Yes.
|
|
||||||
|
|
||||||
/* Here the comment leader should be left intact. */
|
|
||||||
// And so should this one.
|
|
||||||
|
|
||||||
/* Here the comment leader should be left intact. */
|
|
||||||
// And so should this one.
|
|
||||||
|
|
||||||
if (condition) // Remove the next comment leader!
|
|
||||||
// OK, I will.
|
|
||||||
action();
|
|
||||||
|
|
||||||
if (condition) // Remove the next comment leader!
|
|
||||||
// OK, I will.
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:" Test with backspace set to the non-compatible setting
|
|
||||||
/^\d\+ this
|
|
||||||
:set bs=2
|
|
||||||
Avim1
|
|
||||||
Avim2u
|
|
||||||
:set cpo-=<
|
|
||||||
:inoremap <c-u> <left><c-u>
|
|
||||||
Avim3
|
|
||||||
:iunmap <c-u>
|
|
||||||
Avim4
|
|
||||||
:" Test with backspace set to the compatible setting
|
|
||||||
:set bs=
|
|
||||||
A vim5A
|
|
||||||
A vim6Azweiu
|
|
||||||
:inoremap <c-u> <left><c-u>
|
|
||||||
A vim7
|
|
||||||
:set noesckeys
|
|
||||||
ENDTEST
|
|
||||||
1 this shouldn't be deleted
|
|
||||||
2 this shouldn't be deleted
|
|
||||||
3 this shouldn't be deleted
|
|
||||||
4 this should be deleted
|
|
||||||
5 this shouldn't be deleted
|
|
||||||
6 this shouldn't be deleted
|
|
||||||
7 this shouldn't be deleted
|
|
||||||
8 this shouldn't be deleted (not touched yet)
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
/^{/+1
|
|
||||||
:set comments=sO:*\ -,mO:*\ \ ,exO:*/
|
|
||||||
:set comments+=s1:/*,mb:*,ex:*/,://
|
|
||||||
:set comments+=s1:>#,mb:#,ex:#<,:<
|
|
||||||
:set cpoptions-=j joinspaces fo=j
|
|
||||||
:set backspace=eol,start
|
|
||||||
:.,+3join
|
|
||||||
j4J
|
|
||||||
:.,+8join
|
|
||||||
j9J
|
|
||||||
:.,+2join
|
|
||||||
j3J
|
|
||||||
:.,+2join
|
|
||||||
j3J
|
|
||||||
:.,+2join
|
|
||||||
jj3J
|
|
||||||
j:.,+2join
|
|
||||||
jj3J
|
|
||||||
j:.,+5join
|
|
||||||
j6J
|
|
||||||
oSome code!
// Make sure backspacing does not remove this comment leader.0i
|
|
||||||
ENDTEST
|
|
||||||
|
|
||||||
{
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the previous comment leader is not removed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Make sure the previous comment leader is not removed.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* List:
|
|
||||||
* - item1
|
|
||||||
* foo bar baz
|
|
||||||
* foo bar baz
|
|
||||||
* - item2
|
|
||||||
* foo bar baz
|
|
||||||
* foo bar baz
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* List:
|
|
||||||
* - item1
|
|
||||||
* foo bar baz
|
|
||||||
* foo bar baz
|
|
||||||
* - item2
|
|
||||||
* foo bar baz
|
|
||||||
* foo bar baz
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Should the next comment leader be left alone?
|
|
||||||
// Yes.
|
|
||||||
|
|
||||||
// Should the next comment leader be left alone?
|
|
||||||
// Yes.
|
|
||||||
|
|
||||||
/* Here the comment leader should be left intact. */
|
|
||||||
// And so should this one.
|
|
||||||
|
|
||||||
/* Here the comment leader should be left intact. */
|
|
||||||
// And so should this one.
|
|
||||||
|
|
||||||
if (condition) // Remove the next comment leader!
|
|
||||||
// OK, I will.
|
|
||||||
action();
|
|
||||||
|
|
||||||
if (condition) // Remove the next comment leader!
|
|
||||||
// OK, I will.
|
|
||||||
action();
|
|
||||||
|
|
||||||
int i = 7 /* foo *// 3
|
|
||||||
// comment
|
|
||||||
;
|
|
||||||
|
|
||||||
int i = 7 /* foo *// 3
|
|
||||||
// comment
|
|
||||||
;
|
|
||||||
|
|
||||||
># Note that the last character of the ending comment leader (left angle
|
|
||||||
# bracket) is a comment leader itself. Make sure that this comment leader is
|
|
||||||
# not removed from the next line #<
|
|
||||||
< On this line a new comment is opened which spans 2 lines. This comment should
|
|
||||||
< retain its comment leader.
|
|
||||||
|
|
||||||
># Note that the last character of the ending comment leader (left angle
|
|
||||||
# bracket) is a comment leader itself. Make sure that this comment leader is
|
|
||||||
# not removed from the next line #<
|
|
||||||
< On this line a new comment is opened which spans 2 lines. This comment should
|
|
||||||
< retain its comment leader.
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
STARTTEST
|
|
||||||
:g/^STARTTEST/.,/^ENDTEST/d
|
|
||||||
:?firstline?+1,$w! test.out
|
|
||||||
:qa!
|
|
||||||
ENDTEST
|
|
@ -1,97 +0,0 @@
|
|||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
zx cvn. as dfg? hjkl iop! ert ernop
|
|
||||||
zx cvn. as dfg? hjkl iop! ert ernop
|
|
||||||
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
zx cvn. as dfg? hjkl iop! ert enop
|
|
||||||
zx cvn. as dfg? hjkl iop! ert ernop
|
|
||||||
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf. asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
asdfasdf asdf
|
|
||||||
zx cvn. as dfg? hjkl iop! ert a
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
/* Make sure the previous comment leader is not removed. */
|
|
||||||
/* Make sure the previous comment leader is not removed. */
|
|
||||||
// Should the next comment leader be left alone? Yes.
|
|
||||||
// Should the next comment leader be left alone? Yes.
|
|
||||||
/* Here the comment leader should be left intact. */ // And so should this one.
|
|
||||||
/* Here the comment leader should be left intact. */ // And so should this one.
|
|
||||||
if (condition) // Remove the next comment leader! OK, I will.
|
|
||||||
action();
|
|
||||||
if (condition) // Remove the next comment leader! OK, I will.
|
|
||||||
action();
|
|
||||||
}
|
|
||||||
|
|
||||||
1 this shouldn't be deleted
|
|
||||||
2 this shouldn't be deleted
|
|
||||||
3 this shouldn't be deleted
|
|
||||||
4 this should be deleted3
|
|
||||||
|
|
||||||
6 this shouldn't be deleted vim5
|
|
||||||
7 this shouldn't be deleted vim6
|
|
||||||
8 this shouldn't be deleted (not touched yet) vim7
|
|
||||||
|
|
||||||
|
|
||||||
{
|
|
||||||
/* Make sure the previous comment leader is not removed. */
|
|
||||||
/* Make sure the previous comment leader is not removed. */
|
|
||||||
/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
|
|
||||||
/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
|
|
||||||
// Should the next comment leader be left alone? Yes.
|
|
||||||
// Should the next comment leader be left alone? Yes.
|
|
||||||
/* Here the comment leader should be left intact. */ // And so should this one.
|
|
||||||
/* Here the comment leader should be left intact. */ // And so should this one.
|
|
||||||
if (condition) // Remove the next comment leader! OK, I will.
|
|
||||||
action();
|
|
||||||
if (condition) // Remove the next comment leader! OK, I will.
|
|
||||||
action();
|
|
||||||
int i = 7 /* foo *// 3 // comment
|
|
||||||
;
|
|
||||||
int i = 7 /* foo *// 3 // comment
|
|
||||||
;
|
|
||||||
># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
|
|
||||||
># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
|
|
||||||
|
|
||||||
Some code!// Make sure backspacing does not remove this comment leader.
|
|
||||||
}
|
|
||||||
|
|
337
test/functional/legacy/029_join_spec.lua
Normal file
337
test/functional/legacy/029_join_spec.lua
Normal file
@ -0,0 +1,337 @@
|
|||||||
|
-- Test for joining lines with marks in them (and with 'joinspaces' set/reset)
|
||||||
|
|
||||||
|
local helpers = require('test.functional.helpers')
|
||||||
|
local feed, insert, source = helpers.feed, helpers.insert, helpers.source
|
||||||
|
local clear, execute, expect = helpers.clear, helpers.execute, helpers.expect
|
||||||
|
|
||||||
|
describe('joining lines', function()
|
||||||
|
before_each(clear)
|
||||||
|
|
||||||
|
it("keeps marks with different 'joinspaces' settings", function()
|
||||||
|
insert([[
|
||||||
|
firstline
|
||||||
|
asdfasdf.
|
||||||
|
asdf
|
||||||
|
asdfasdf.
|
||||||
|
asdf
|
||||||
|
asdfasdf.
|
||||||
|
asdf
|
||||||
|
asdfasdf.
|
||||||
|
asdf
|
||||||
|
asdfasdf.
|
||||||
|
asdf
|
||||||
|
asdfasdf.
|
||||||
|
asdf
|
||||||
|
asdfasdf.
|
||||||
|
asdf
|
||||||
|
asdfasdf
|
||||||
|
asdf
|
||||||
|
asdfasdf
|
||||||
|
asdf
|
||||||
|
asdfasdf
|
||||||
|
asdf
|
||||||
|
asdfasdf
|
||||||
|
asdf
|
||||||
|
asdfasdf
|
||||||
|
asdf
|
||||||
|
asdfasdf
|
||||||
|
asdf
|
||||||
|
asdfasdf
|
||||||
|
asdf
|
||||||
|
zx cvn.
|
||||||
|
as dfg?
|
||||||
|
hjkl iop!
|
||||||
|
ert
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- Switch off 'joinspaces', then join some lines in the buffer using "J".
|
||||||
|
-- Also set a few marks and record their movement when joining lines.
|
||||||
|
execute('set nojoinspaces')
|
||||||
|
execute('/firstline/')
|
||||||
|
feed('j"td/^$/<cr>')
|
||||||
|
feed('PJjJjJjJjJjJjJjJjJjJjJjJjJjJ')
|
||||||
|
feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$p')
|
||||||
|
|
||||||
|
-- Do the same with 'joinspaces' on.
|
||||||
|
execute('set joinspaces')
|
||||||
|
feed('j"tp')
|
||||||
|
feed('JjJjJjJjJjJjJjJjJjJjJjJjJjJ')
|
||||||
|
feed('j05lmx2j06lmy2k4Jy3l$p`xyl$p`yy2l$po<esc>')
|
||||||
|
|
||||||
|
execute('1d')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
zx cvn. as dfg? hjkl iop! ert ernop
|
||||||
|
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf. asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
asdfasdf asdf
|
||||||
|
zx cvn. as dfg? hjkl iop! ert enop
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("removes comment leaders with 'joinspaces' off", function()
|
||||||
|
insert([[
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the previous comment leader is not removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the previous comment leader is not removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Should the next comment leader be left alone?
|
||||||
|
// Yes.
|
||||||
|
|
||||||
|
// Should the next comment leader be left alone?
|
||||||
|
// Yes.
|
||||||
|
|
||||||
|
/* Here the comment leader should be left intact. */
|
||||||
|
// And so should this one.
|
||||||
|
|
||||||
|
/* Here the comment leader should be left intact. */
|
||||||
|
// And so should this one.
|
||||||
|
|
||||||
|
if (condition) // Remove the next comment leader!
|
||||||
|
// OK, I will.
|
||||||
|
action();
|
||||||
|
|
||||||
|
if (condition) // Remove the next comment leader!
|
||||||
|
// OK, I will.
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
|
||||||
|
execute('/^{/+1')
|
||||||
|
execute('set comments=s1:/*,mb:*,ex:*/,://')
|
||||||
|
execute('set nojoinspaces')
|
||||||
|
execute('set backspace=eol,start')
|
||||||
|
|
||||||
|
-- With 'joinspaces' switched off, join lines using both "J" and :join and
|
||||||
|
-- verify that comment leaders are stripped or kept as appropriate.
|
||||||
|
execute('.,+3join')
|
||||||
|
feed('j4J<cr>')
|
||||||
|
execute('.,+2join')
|
||||||
|
feed('j3J<cr>')
|
||||||
|
execute('.,+2join')
|
||||||
|
feed('j3J<cr>')
|
||||||
|
execute('.,+2join')
|
||||||
|
feed('jj3J<cr>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
{
|
||||||
|
/* Make sure the previous comment leader is not removed. */
|
||||||
|
/* Make sure the previous comment leader is not removed. */
|
||||||
|
// Should the next comment leader be left alone? Yes.
|
||||||
|
// Should the next comment leader be left alone? Yes.
|
||||||
|
/* Here the comment leader should be left intact. */ // And so should this one.
|
||||||
|
/* Here the comment leader should be left intact. */ // And so should this one.
|
||||||
|
if (condition) // Remove the next comment leader! OK, I will.
|
||||||
|
action();
|
||||||
|
if (condition) // Remove the next comment leader! OK, I will.
|
||||||
|
action();
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
-- This test case has nothing to do with joining lines.
|
||||||
|
it("Ctrl-u and 'backspace' compatibility", function()
|
||||||
|
-- Notice that the buffer text, which is intended to helpfully hint at
|
||||||
|
-- what's being done in the test, is off by one line. (For example, "this
|
||||||
|
-- should be deleted" should not be deleted, but the line below it should,
|
||||||
|
-- and is.) This is likely a mistake, but was kept here for consistency.
|
||||||
|
insert([[
|
||||||
|
1 this shouldn't be deleted
|
||||||
|
2 this shouldn't be deleted
|
||||||
|
3 this shouldn't be deleted
|
||||||
|
4 this should be deleted
|
||||||
|
5 this shouldn't be deleted
|
||||||
|
6 this shouldn't be deleted
|
||||||
|
7 this shouldn't be deleted
|
||||||
|
8 this shouldn't be deleted (not touched yet)
|
||||||
|
]])
|
||||||
|
|
||||||
|
-- As mentioned above, we mimic the wrong initial cursor position in the old
|
||||||
|
-- test by advancing one line further.
|
||||||
|
execute([[/^\d\+ this]], '+1')
|
||||||
|
|
||||||
|
-- Test with the default 'backspace' setting.
|
||||||
|
feed('Avim1<c-u><esc><cr>')
|
||||||
|
feed('Avim2<c-g>u<c-u><esc><cr>')
|
||||||
|
execute('set cpo-=<')
|
||||||
|
execute('inoremap <c-u> <left><c-u>')
|
||||||
|
feed('Avim3<c-u><esc><cr>')
|
||||||
|
execute('iunmap <c-u>')
|
||||||
|
feed('Avim4<c-u><c-u><esc><cr>')
|
||||||
|
|
||||||
|
-- Test with 'backspace' set to the compatible setting.
|
||||||
|
execute('set backspace=')
|
||||||
|
feed('A vim5<esc>A<c-u><c-u><esc><cr>')
|
||||||
|
feed('A vim6<esc>Azwei<c-g>u<c-u><esc><cr>')
|
||||||
|
execute('inoremap <c-u> <left><c-u>')
|
||||||
|
feed('A vim7<c-u><c-u><esc><cr>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
1 this shouldn't be deleted
|
||||||
|
2 this shouldn't be deleted
|
||||||
|
3 this shouldn't be deleted
|
||||||
|
4 this should be deleted3
|
||||||
|
|
||||||
|
6 this shouldn't be deleted vim5
|
||||||
|
7 this shouldn't be deleted vim6
|
||||||
|
8 this shouldn't be deleted (not touched yet) vim7
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it("removes comment leaders with 'joinspaces' on", function()
|
||||||
|
insert([[
|
||||||
|
{
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the previous comment leader is not removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Make sure the previous comment leader is not removed.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* List:
|
||||||
|
* - item1
|
||||||
|
* foo bar baz
|
||||||
|
* foo bar baz
|
||||||
|
* - item2
|
||||||
|
* foo bar baz
|
||||||
|
* foo bar baz
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* List:
|
||||||
|
* - item1
|
||||||
|
* foo bar baz
|
||||||
|
* foo bar baz
|
||||||
|
* - item2
|
||||||
|
* foo bar baz
|
||||||
|
* foo bar baz
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Should the next comment leader be left alone?
|
||||||
|
// Yes.
|
||||||
|
|
||||||
|
// Should the next comment leader be left alone?
|
||||||
|
// Yes.
|
||||||
|
|
||||||
|
/* Here the comment leader should be left intact. */
|
||||||
|
// And so should this one.
|
||||||
|
|
||||||
|
/* Here the comment leader should be left intact. */
|
||||||
|
// And so should this one.
|
||||||
|
|
||||||
|
if (condition) // Remove the next comment leader!
|
||||||
|
// OK, I will.
|
||||||
|
action();
|
||||||
|
|
||||||
|
if (condition) // Remove the next comment leader!
|
||||||
|
// OK, I will.
|
||||||
|
action();
|
||||||
|
|
||||||
|
int i = 7 /* foo *// 3
|
||||||
|
// comment
|
||||||
|
;
|
||||||
|
|
||||||
|
int i = 7 /* foo *// 3
|
||||||
|
// comment
|
||||||
|
;
|
||||||
|
|
||||||
|
># Note that the last character of the ending comment leader (left angle
|
||||||
|
# bracket) is a comment leader itself. Make sure that this comment leader is
|
||||||
|
# not removed from the next line #<
|
||||||
|
< On this line a new comment is opened which spans 2 lines. This comment should
|
||||||
|
< retain its comment leader.
|
||||||
|
|
||||||
|
># Note that the last character of the ending comment leader (left angle
|
||||||
|
# bracket) is a comment leader itself. Make sure that this comment leader is
|
||||||
|
# not removed from the next line #<
|
||||||
|
< On this line a new comment is opened which spans 2 lines. This comment should
|
||||||
|
< retain its comment leader.
|
||||||
|
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
|
||||||
|
execute('/^{/+1')
|
||||||
|
execute([[set comments=sO:*\ -,mO:*\ \ ,exO:*/]])
|
||||||
|
execute('set comments+=s1:/*,mb:*,ex:*/,://')
|
||||||
|
execute('set comments+=s1:>#,mb:#,ex:#<,:<')
|
||||||
|
execute('set backspace=eol,start')
|
||||||
|
|
||||||
|
-- With 'joinspaces' on (the default setting), again join lines and verify
|
||||||
|
-- that comment leaders are stripped or kept as appropriate.
|
||||||
|
execute('.,+3join')
|
||||||
|
feed('j4J<cr>')
|
||||||
|
execute('.,+8join')
|
||||||
|
feed('j9J<cr>')
|
||||||
|
execute('.,+2join')
|
||||||
|
feed('j3J<cr>')
|
||||||
|
execute('.,+2join')
|
||||||
|
feed('j3J<cr>')
|
||||||
|
execute('.,+2join')
|
||||||
|
feed('jj3J<cr>')
|
||||||
|
feed('j')
|
||||||
|
execute('.,+2join')
|
||||||
|
feed('jj3J<cr>')
|
||||||
|
feed('j')
|
||||||
|
execute('.,+5join')
|
||||||
|
feed('j6J<cr>')
|
||||||
|
feed('oSome code!<cr>// Make sure backspacing does not remove this comment leader.<esc>0i<bs><esc>')
|
||||||
|
|
||||||
|
expect([[
|
||||||
|
{
|
||||||
|
/* Make sure the previous comment leader is not removed. */
|
||||||
|
/* Make sure the previous comment leader is not removed. */
|
||||||
|
/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
|
||||||
|
/* List: item1 foo bar baz foo bar baz item2 foo bar baz foo bar baz */
|
||||||
|
// Should the next comment leader be left alone? Yes.
|
||||||
|
// Should the next comment leader be left alone? Yes.
|
||||||
|
/* Here the comment leader should be left intact. */ // And so should this one.
|
||||||
|
/* Here the comment leader should be left intact. */ // And so should this one.
|
||||||
|
if (condition) // Remove the next comment leader! OK, I will.
|
||||||
|
action();
|
||||||
|
if (condition) // Remove the next comment leader! OK, I will.
|
||||||
|
action();
|
||||||
|
int i = 7 /* foo *// 3 // comment
|
||||||
|
;
|
||||||
|
int i = 7 /* foo *// 3 // comment
|
||||||
|
;
|
||||||
|
># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
|
||||||
|
># Note that the last character of the ending comment leader (left angle bracket) is a comment leader itself. Make sure that this comment leader is not removed from the next line #< < On this line a new comment is opened which spans 2 lines. This comment should retain its comment leader.
|
||||||
|
|
||||||
|
Some code!// Make sure backspacing does not remove this comment leader.
|
||||||
|
}
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
end)
|
Loading…
Reference in New Issue
Block a user