mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
vim-patch:8.1.1723: heredoc assignment has no room for new features
Problem: Heredoc assignment has no room for new features. (FUJIWARA Takuya)
Solution: Require the marker does not start with a lower case character.
(closes vim/vim#4705)
2458200729
This commit is contained in:
parent
fcc24d0df3
commit
3b894b1cb1
@ -9779,19 +9779,18 @@ This does NOT work: >
|
||||
Like above, but append/add/subtract the value for each
|
||||
|List| item.
|
||||
|
||||
*:let=<<* *:let-heredoc* *E990* *E991*
|
||||
*:let=<<* *:let-heredoc*
|
||||
*E990* *E991* *E172* *E221*
|
||||
:let {var-name} =<< [trim] {marker}
|
||||
text...
|
||||
text...
|
||||
{marker}
|
||||
Set internal variable {var-name} to a List containing
|
||||
the lines of text bounded by the string {marker}.
|
||||
{marker} must not contain white space.
|
||||
{marker} cannot start with a lower case character.
|
||||
The last line should end only with the {marker} string
|
||||
without any other character. Watch out for white
|
||||
space after {marker}!
|
||||
If {marker} is not supplied, then "." is used as the
|
||||
default marker.
|
||||
|
||||
Without "trim" any white space characters in the lines
|
||||
of text are preserved. If "trim" is specified before
|
||||
|
@ -1548,7 +1548,7 @@ heredoc_get(exarg_T *eap, char_u *cmd)
|
||||
text_indent_len = -1;
|
||||
}
|
||||
|
||||
// The marker is the next word. Default marker is "."
|
||||
// The marker is the next word.
|
||||
if (*cmd != NUL && *cmd != '"') {
|
||||
marker = skipwhite(cmd);
|
||||
p = skiptowhite(marker);
|
||||
@ -1557,8 +1557,13 @@ heredoc_get(exarg_T *eap, char_u *cmd)
|
||||
return NULL;
|
||||
}
|
||||
*p = NUL;
|
||||
if (islower(*marker)) {
|
||||
EMSG(_("E221: Marker cannot start with lower case letter"));
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
marker = (char_u *)".";
|
||||
EMSG(_("E172: Missing marker"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
list_T *l = tv_list_alloc(0);
|
||||
|
@ -153,14 +153,28 @@ func Test_let_heredoc_fails()
|
||||
call assert_fails('source XheredocFail', 'E126:')
|
||||
call delete('XheredocFail')
|
||||
|
||||
let text =<< trim END
|
||||
let text =<< trim CodeEnd
|
||||
func MissingEnd()
|
||||
let v =<< END
|
||||
endfunc
|
||||
END
|
||||
CodeEnd
|
||||
call writefile(text, 'XheredocWrong')
|
||||
call assert_fails('source XheredocWrong', 'E126:')
|
||||
call delete('XheredocWrong')
|
||||
|
||||
let text =<< trim TEXTend
|
||||
let v =<< " comment
|
||||
TEXTend
|
||||
call writefile(text, 'XheredocNoMarker')
|
||||
call assert_fails('source XheredocNoMarker', 'E172:')
|
||||
call delete('XheredocNoMarker')
|
||||
|
||||
let text =<< trim TEXTend
|
||||
let v =<< text
|
||||
TEXTend
|
||||
call writefile(text, 'XheredocBadMarker')
|
||||
call assert_fails('source XheredocBadMarker', 'E221:')
|
||||
call delete('XheredocBadMarker')
|
||||
endfunc
|
||||
|
||||
" Test for the setting a variable using the heredoc syntax
|
||||
@ -173,9 +187,9 @@ END
|
||||
|
||||
call assert_equal(["Some sample text", "\tText with indent", " !@#$%^&*()-+_={}|[]\\~`:\";'<>?,./"], var1)
|
||||
|
||||
let var2 =<<
|
||||
let var2 =<< XXX
|
||||
Editor
|
||||
.
|
||||
XXX
|
||||
call assert_equal(['Editor'], var2)
|
||||
|
||||
let var3 =<<END
|
||||
@ -207,9 +221,9 @@ END
|
||||
!!!
|
||||
call assert_equal(['Line1', ' line2', "\tLine3", '!!!',], var1)
|
||||
|
||||
let var1 =<< trim
|
||||
let var1 =<< trim XX
|
||||
Line1
|
||||
.
|
||||
XX
|
||||
call assert_equal(['Line1'], var1)
|
||||
|
||||
" ignore "endfunc"
|
||||
@ -241,16 +255,16 @@ END
|
||||
call assert_equal(['something', 'python << xx'], var1)
|
||||
|
||||
" ignore "append"
|
||||
let var1 =<<
|
||||
let var1 =<< E
|
||||
something
|
||||
app
|
||||
.
|
||||
E
|
||||
call assert_equal(['something', 'app'], var1)
|
||||
|
||||
" ignore "append" with trim
|
||||
let var1 =<< trim
|
||||
let var1 =<< trim END
|
||||
something
|
||||
app
|
||||
.
|
||||
END
|
||||
call assert_equal(['something', 'app'], var1)
|
||||
endfunc
|
||||
|
Loading…
Reference in New Issue
Block a user