mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 14:08:32 +00:00
vim-patch:8.0.1231: expanding file name drops dash
Problem: Expanding file name drops dash. (stucki)
Solution: Use the right position. (Christian Brabandt, closes vim/vim#2184)
c312b8b87a
This commit is contained in:
@@ -8521,9 +8521,13 @@ eval_vars (
|
||||
if (*s == '<') /* "#<99" uses v:oldfiles */
|
||||
++s;
|
||||
i = getdigits_int(&s);
|
||||
if (s == src + 2 && src[1] == '-') {
|
||||
// just a minus sign, don't skip over it
|
||||
s--;
|
||||
}
|
||||
*usedlen = (size_t)(s - src); /* length of what we expand */
|
||||
|
||||
if (src[1] == '<') {
|
||||
if (src[1] == '<' && i != 0) {
|
||||
if (*usedlen < 2) {
|
||||
/* Should we give an error message for #<text? */
|
||||
*usedlen = 1;
|
||||
@@ -8536,6 +8540,9 @@ eval_vars (
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
if (i == 0 && src[1] == '<' && *usedlen > 1) {
|
||||
*usedlen = 1;
|
||||
}
|
||||
buf = buflist_findnr(i);
|
||||
if (buf == NULL) {
|
||||
*errormsg = (char_u *)_(
|
||||
|
@@ -380,6 +380,27 @@ func Test_cmdline_complete_user_cmd()
|
||||
delcommand Foo
|
||||
endfunc
|
||||
|
||||
func Test_cmdline_write_alternatefile()
|
||||
new
|
||||
call setline('.', ['one', 'two'])
|
||||
f foo.txt
|
||||
new
|
||||
f #-A
|
||||
call assert_equal('foo.txt-A', expand('%'))
|
||||
f #<-B.txt
|
||||
call assert_equal('foo-B.txt', expand('%'))
|
||||
f %<
|
||||
call assert_equal('foo-B', expand('%'))
|
||||
new
|
||||
call assert_fails('f #<', 'E95')
|
||||
bw!
|
||||
f foo-B.txt
|
||||
f %<-A
|
||||
call assert_equal('foo-B-A', expand('%'))
|
||||
bw!
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
" using a leading backslash here
|
||||
set cpo+=C
|
||||
|
||||
|
Reference in New Issue
Block a user