aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/edit.c31
-rw-r--r--src/nvim/eval.c5
-rw-r--r--src/nvim/ex_docmd.c18
-rw-r--r--src/nvim/generators/gen_events.lua15
-rw-r--r--src/nvim/main.c10
-rw-r--r--src/nvim/normal.c14
-rw-r--r--src/nvim/testdir/test_edit.vim40
-rw-r--r--src/nvim/testdir/test_functions.vim25
-rw-r--r--src/nvim/testdir/test_gf.vim27
9 files changed, 138 insertions, 47 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index c20758cb0b..1f18fc36fd 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -4132,7 +4132,6 @@ ins_compl_next (
)
{
int num_matches = -1;
- int i;
int todo = count;
compl_T *found_compl = NULL;
int found_end = FALSE;
@@ -4294,15 +4293,27 @@ ins_compl_next (
* Truncate the file name to avoid a wait for return.
*/
if (compl_shown_match->cp_fname != NULL) {
- STRCPY(IObuff, "match in file ");
- i = (vim_strsize(compl_shown_match->cp_fname) + 16) - sc_col;
- if (i <= 0)
- i = 0;
- else
- STRCAT(IObuff, "<");
- STRCAT(IObuff, compl_shown_match->cp_fname + i);
- msg(IObuff);
- redraw_cmdline = FALSE; /* don't overwrite! */
+ char *lead = _("match in file");
+ int space = sc_col - vim_strsize((char_u *)lead) - 2;
+ char_u *s;
+ char_u *e;
+
+ if (space > 0) {
+ // We need the tail that fits. With double-byte encoding going
+ // back from the end is very slow, thus go from the start and keep
+ // the text that fits in "space" between "s" and "e".
+ for (s = e = compl_shown_match->cp_fname; *e != NUL; MB_PTR_ADV(e)) {
+ space -= ptr2cells(e);
+ while (space < 0) {
+ space += ptr2cells(s);
+ MB_PTR_ADV(s);
+ }
+ }
+ vim_snprintf((char *)IObuff, IOSIZE, "%s %s%s", lead,
+ s > compl_shown_match->cp_fname ? "<" : "", s);
+ msg(IObuff);
+ redraw_cmdline = false; // don't overwrite!
+ }
}
return num_matches;
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index eb437931d4..d8d785395c 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -15066,9 +15066,10 @@ static void f_sha256(typval_T *argvars, typval_T *rettv, FunPtr fptr)
*/
static void f_shellescape(typval_T *argvars, typval_T *rettv, FunPtr fptr)
{
+ const bool do_special = non_zero_arg(&argvars[1]);
+
rettv->vval.v_string = vim_strsave_shellescape(
- (const char_u *)tv_get_string(&argvars[0]), non_zero_arg(&argvars[1]),
- true);
+ (const char_u *)tv_get_string(&argvars[0]), do_special, do_special);
rettv->v_type = VAR_STRING;
}
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 9590a3715e..2f41080a41 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -188,15 +188,8 @@ static void restore_dbg_stuff(struct dbg_stuff *dsp)
current_exception = dsp->current_exception;
}
-
-/*
- * do_exmode(): Repeatedly get commands for the "Ex" mode, until the ":vi"
- * command is given.
- */
-void
-do_exmode (
- int improved /* TRUE for "improved Ex" mode */
-)
+/// Repeatedly get commands for Ex mode, until the ":vi" command is given.
+void do_exmode(int improved)
{
int save_msg_scroll;
int prev_msg_row;
@@ -232,11 +225,8 @@ do_exmode (
changedtick = curbuf->b_changedtick;
prev_msg_row = msg_row;
prev_line = curwin->w_cursor.lnum;
- if (improved) {
- cmdline_row = msg_row;
- do_cmdline(NULL, getexline, NULL, 0);
- } else
- do_cmdline(NULL, getexmodeline, NULL, DOCMD_NOWAIT);
+ cmdline_row = msg_row;
+ do_cmdline(NULL, getexline, NULL, 0);
lines_left = Rows - 1;
if ((prev_line != curwin->w_cursor.lnum
diff --git a/src/nvim/generators/gen_events.lua b/src/nvim/generators/gen_events.lua
index 75e0b3da3a..d03c787b2b 100644
--- a/src/nvim/generators/gen_events.lua
+++ b/src/nvim/generators/gen_events.lua
@@ -25,25 +25,22 @@ static const struct event_name {
} event_names[] = {]])
for i, event in ipairs(events) do
- if i > 1 then
- comma = ',\n'
- else
- comma = '\n'
+ enum_tgt:write(('\n EVENT_%s = %u,'):format(event:upper(), i - 1))
+ names_tgt:write(('\n {%u, "%s", EVENT_%s},'):format(#event, event, event:upper()))
+ if i == #events then -- Last item.
+ enum_tgt:write(('\n NUM_EVENTS = %u,'):format(i))
end
- enum_tgt:write(('%s EVENT_%s = %u'):format(comma, event:upper(), i - 1))
- names_tgt:write(('%s {%u, "%s", EVENT_%s}'):format(comma, #event, event, event:upper()))
end
for alias, event in pairs(aliases) do
- names_tgt:write((',\n {%u, "%s", EVENT_%s}'):format(#alias, alias, event:upper()))
+ names_tgt:write(('\n {%u, "%s", EVENT_%s},'):format(#alias, alias, event:upper()))
end
-names_tgt:write(',\n {0, NULL, (event_T)0}')
+names_tgt:write('\n {0, NULL, (event_T)0},')
enum_tgt:write('\n} event_T;\n')
names_tgt:write('\n};\n')
-enum_tgt:write(('\n#define NUM_EVENTS %u\n'):format(#events))
names_tgt:write('\nstatic AutoPat *first_autopat[NUM_EVENTS] = {\n ')
line_len = 1
for i = 1,((#events) - 1) do
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 8d98f9e915..ea43b93b30 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -301,9 +301,11 @@ int main(int argc, char **argv)
// Read ex-commands if invoked with "-es".
//
bool reading_tty = !headless_mode
+ && !silent_mode
&& (params.input_isatty || params.output_isatty
|| params.err_isatty);
- bool reading_excmds = !params.input_isatty && silent_mode
+ bool reading_excmds = !params.input_isatty
+ && silent_mode
&& exmode_active == EXMODE_NORMAL;
if (reading_tty || reading_excmds) {
// One of the startup commands (arguments, sourced scripts or plugins) may
@@ -872,7 +874,7 @@ static void command_line_scan(mparm_T *parmp)
exmode_active = EXMODE_NORMAL;
break;
}
- case 'E': { // "-E" Improved Ex mode
+ case 'E': { // "-E" Ex mode
exmode_active = EXMODE_VIM;
break;
}
@@ -1896,8 +1898,8 @@ static void usage(void)
mch_msg("\n");
mch_msg(_(" -b Binary mode\n"));
mch_msg(_(" -d Diff mode\n"));
- mch_msg(_(" -e, -E Ex mode, Improved Ex mode\n"));
- mch_msg(_(" -es Silent (batch) mode\n"));
+ mch_msg(_(" -e, -E Ex mode\n"));
+ mch_msg(_(" -es, -Es Silent (batch) mode\n"));
mch_msg(_(" -h, --help Print this help message\n"));
mch_msg(_(" -i <shada> Use this shada file\n"));
mch_msg(_(" -m Modifications (writing files) not allowed\n"));
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index a7c4c255b7..b959ea08f3 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -5234,9 +5234,9 @@ static void nv_gotofile(cmdarg_T *cap)
(void)autowrite(curbuf, false);
}
setpcmark();
- (void)do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
- buf_hide(curbuf) ? ECMD_HIDE : 0, curwin);
- if (cap->nchar == 'F' && lnum >= 0) {
+ if (do_ecmd(0, ptr, NULL, NULL, ECMD_LAST,
+ buf_hide(curbuf) ? ECMD_HIDE : 0, curwin) == OK
+ && cap->nchar == 'F' && lnum >= 0) {
curwin->w_cursor.lnum = lnum;
check_cursor_lnum();
beginline(BL_SOL | BL_FIX);
@@ -7151,7 +7151,7 @@ static void set_op_var(int optype)
assert(opchar0 >= 0 && opchar0 <= UCHAR_MAX);
opchars[0] = (char) opchar0;
- int opchar1 = get_extra_op_char(optype);
+ int opchar1 = get_extra_op_char(optype);
assert(opchar1 >= 0 && opchar1 <= UCHAR_MAX);
opchars[1] = (char) opchar1;
@@ -7464,8 +7464,10 @@ static void nv_esc(cmdarg_T *cap)
if (restart_edit == 0
&& cmdwin_type == 0
&& !VIsual_active
- && no_reason)
- MSG(_("Type :quit<Enter> to exit Nvim"));
+ && no_reason) {
+ MSG(_("Type :qa! and press <Enter> to abandon all changes"
+ " and exit Nvim"));
+ }
/* Don't reset "restart_edit" when 'insertmode' is set, it won't be
* set again below when halfway through a mapping. */
diff --git a/src/nvim/testdir/test_edit.vim b/src/nvim/testdir/test_edit.vim
index 8f815478c2..d2474c06fe 100644
--- a/src/nvim/testdir/test_edit.vim
+++ b/src/nvim/testdir/test_edit.vim
@@ -1323,3 +1323,43 @@ func Test_edit_quit()
only
endfunc
+func Test_edit_complete_very_long_name()
+ if !has('unix')
+ " Long directory names only work on Unix.
+ return
+ endif
+
+ let dirname = getcwd() . "/Xdir"
+ let longdirname = dirname . repeat('/' . repeat('d', 255), 4)
+ try
+ call mkdir(longdirname, 'p')
+ catch /E739:/
+ " Long directory name probably not supported.
+ call delete(dirname, 'rf')
+ return
+ endtry
+
+ " Try to get the Vim window position before setting 'columns'.
+ let winposx = getwinposx()
+ let winposy = getwinposy()
+ let save_columns = &columns
+ " Need at least about 1100 columns to reproduce the problem.
+ set columns=2000
+ call assert_equal(2000, &columns)
+ set noswapfile
+
+ let longfilename = longdirname . '/' . repeat('a', 255)
+ call writefile(['Totum', 'Table'], longfilename)
+ new
+ exe "next Xfile " . longfilename
+ exe "normal iT\<C-N>"
+
+ bwipe!
+ exe 'bwipe! ' . longfilename
+ call delete(dirname, 'rf')
+ let &columns = save_columns
+ if winposx >= 0 && winposy >= 0
+ exe 'winpos ' . winposx . ' ' . winposy
+ endif
+ set swapfile&
+endfunc
diff --git a/src/nvim/testdir/test_functions.vim b/src/nvim/testdir/test_functions.vim
index 8a82493ab6..8847653498 100644
--- a/src/nvim/testdir/test_functions.vim
+++ b/src/nvim/testdir/test_functions.vim
@@ -766,3 +766,28 @@ func Test_balloon_show()
call balloon_show('hi!')
endif
endfunc
+
+func Test_shellescape()
+ let save_shell = &shell
+ set shell=bash
+ call assert_equal("'text'", shellescape('text'))
+ call assert_equal("'te\"xt'", shellescape('te"xt'))
+ call assert_equal("'te'\\''xt'", shellescape("te'xt"))
+
+ call assert_equal("'te%xt'", shellescape("te%xt"))
+ call assert_equal("'te\\%xt'", shellescape("te%xt", 1))
+ call assert_equal("'te#xt'", shellescape("te#xt"))
+ call assert_equal("'te\\#xt'", shellescape("te#xt", 1))
+ call assert_equal("'te!xt'", shellescape("te!xt"))
+ call assert_equal("'te\\!xt'", shellescape("te!xt", 1))
+
+ call assert_equal("'te\nxt'", shellescape("te\nxt"))
+ call assert_equal("'te\\\nxt'", shellescape("te\nxt", 1))
+ set shell=tcsh
+ call assert_equal("'te\\!xt'", shellescape("te!xt"))
+ call assert_equal("'te\\\\!xt'", shellescape("te!xt", 1))
+ call assert_equal("'te\\\nxt'", shellescape("te\nxt"))
+ call assert_equal("'te\\\\\nxt'", shellescape("te\nxt", 1))
+
+ let &shell = save_shell
+endfunc
diff --git a/src/nvim/testdir/test_gf.vim b/src/nvim/testdir/test_gf.vim
index c4aa6f9218..ef1bf1075b 100644
--- a/src/nvim/testdir/test_gf.vim
+++ b/src/nvim/testdir/test_gf.vim
@@ -1,7 +1,7 @@
" This is a test if a URL is recognized by "gf", with the cursor before and
" after the "://". Also test ":\\".
-function! Test_gf_url()
+func Test_gf_url()
enew!
call append(0, [
\ "first test for URL://machine.name/tmp/vimtest2a and other text",
@@ -30,4 +30,27 @@ function! Test_gf_url()
set isf&vim
enew!
-endfunction
+endfunc
+
+func Test_gF()
+ new
+ call setline(1, ['111', '222', '333', '444'])
+ w! Xfile
+ close
+ new
+ set isfname-=:
+ call setline(1, ['one', 'Xfile:3', 'three'])
+ 2
+ call assert_fails('normal gF', 'E37:')
+ call assert_equal(2, getcurpos()[1])
+ w! Xfile2
+ normal gF
+ call assert_equal('Xfile', bufname('%'))
+ call assert_equal(3, getcurpos()[1])
+
+ set isfname&
+ call delete('Xfile')
+ call delete('Xfile2')
+ bwipe Xfile
+ bwipe Xfile2
+endfunc