From 30b29a36e80bfeed50bb6ea618401fe35100490f Mon Sep 17 00:00:00 2001 From: bfredl Date: Thu, 9 Feb 2023 20:56:30 +0100 Subject: refactor(ui): remove some superfluous ui_flush() calls - mapping has no business saving and restoring the low-level UI cursor. The cursor will be put in a reasonable position after input is processed, chill out. - TUI handles output needed for suspend - vgetc() family of function does flushing --- src/nvim/ex_docmd.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index a24e8458a6..017787f238 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -4838,13 +4838,9 @@ static void ex_stop(exarg_T *eap) } apply_autocmds(EVENT_VIMSUSPEND, NULL, NULL, false, NULL); - // TODO(bfredl): the TUI should do this on suspend - ui_cursor_goto(Rows - 1, 0); - ui_call_grid_scroll(1, 0, Rows, 0, Columns, 1, 0); + ui_call_suspend(); ui_flush(); - ui_call_suspend(); // call machine specific function - ui_flush(); maketitle(); resettitle(); // force updating the title ui_refresh(); // may have resized window -- cgit From 7224c889e0d5d70b99ae377036baa6377c33a568 Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 10:25:24 +0100 Subject: build: enable MSVC level 3 warnings (#21934) MSVC has 4 different warning levels: 1 (severe), 2 (significant), 3 (production quality) and 4 (informational). Enabling level 3 warnings mostly revealed conversion problems, similar to GCC/clang -Wconversion flag. --- src/nvim/ex_docmd.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 017787f238..8440c45a9c 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1311,16 +1311,16 @@ static void parse_register(exarg_T *eap) } // Change line1 and line2 of Ex command to use count -void set_cmd_count(exarg_T *eap, long count, bool validate) +void set_cmd_count(exarg_T *eap, linenr_T count, bool validate) { if (eap->addr_type != ADDR_LINES) { // e.g. :buffer 2, :sleep 3 - eap->line2 = (linenr_T)count; + eap->line2 = count; if (eap->addr_count == 0) { eap->addr_count = 1; } } else { eap->line1 = eap->line2; - eap->line2 += (linenr_T)count - 1; + eap->line2 += count - 1; eap->addr_count++; // Be vi compatible: no error message for out of range. if (validate && eap->line2 > curbuf->b_ml.ml_line_count) { @@ -1338,7 +1338,7 @@ static int parse_count(exarg_T *eap, char **errormsg, bool validate) if ((eap->argt & EX_COUNT) && ascii_isdigit(*eap->arg) && (!(eap->argt & EX_BUFNAME) || *(p = skipdigits(eap->arg + 1)) == NUL || ascii_iswhite(*p))) { - long n = getdigits_long(&eap->arg, false, -1); + linenr_T n = getdigits_int32(&eap->arg, false, -1); eap->arg = skipwhite(eap->arg); if (eap->args != NULL) { -- cgit From 4be6c6cf0ddf5e31d4103cb5df06651ba6f4897b Mon Sep 17 00:00:00 2001 From: dundargoc <33953936+dundargoc@users.noreply.github.com> Date: Sat, 11 Feb 2023 11:05:57 +0100 Subject: refactor: replace char_u with char (#21901) refactor: replace char_u with char Work on https://github.com/neovim/neovim/issues/459 --- src/nvim/ex_docmd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 8440c45a9c..f460b4b93f 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3200,7 +3200,7 @@ char *skip_range(const char *cmd, int *ctx) } // Skip ":" and white space. - cmd = skip_colon_white((char *)cmd, false); + cmd = skip_colon_white(cmd, false); return (char *)cmd; } @@ -4011,7 +4011,7 @@ static char *getargcmd(char **argp) if (*arg == '+') { // +[command] arg++; if (ascii_isspace(*arg) || *arg == '\0') { - command = (char *)dollar_command; + command = dollar_command; } else { command = arg; arg = skip_cmd_arg(command, true); @@ -4401,7 +4401,7 @@ static int check_more(int message, bool forceit) if ((p_confirm || (cmdmod.cmod_flags & CMOD_CONFIRM)) && curbuf->b_fname != NULL) { char buff[DIALOG_MSG_SIZE]; - vim_snprintf((char *)buff, DIALOG_MSG_SIZE, + vim_snprintf(buff, DIALOG_MSG_SIZE, NGETTEXT("%d more file to edit. Quit anyway?", "%d more files to edit. Quit anyway?", n), n); if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) { @@ -4769,7 +4769,7 @@ void tabpage_close_other(tabpage_T *tp, int forceit) // Limit to 1000 windows, autocommands may add a window while we close // one. OK, so I'm paranoid... while (++done < 1000) { - snprintf((char *)prev_idx, sizeof(prev_idx), "%i", tabpage_index(tp)); + snprintf(prev_idx, sizeof(prev_idx), "%i", tabpage_index(tp)); win_T *wp = tp->tp_lastwin; ex_win_close(forceit, wp, tp); @@ -6748,7 +6748,7 @@ char *eval_vars(char *src, const char *srcstart, size_t *usedlen, linenr_T *lnum // Note: In "\\%" the % is also not recognized! if (src > srcstart && src[-1] == '\\') { *usedlen = 0; - STRMOVE(src - 1, (char *)src); // remove backslash + STRMOVE(src - 1, src); // remove backslash return NULL; } @@ -6925,7 +6925,7 @@ char *eval_vars(char *src, const char *srcstart, size_t *usedlen, linenr_T *lnum *errormsg = _("E961: no line number to use for \"\""); return NULL; } - snprintf((char *)strbuf, sizeof(strbuf), "%" PRIdLINENR, + snprintf(strbuf, sizeof(strbuf), "%" PRIdLINENR, current_sctx.sc_lnum + SOURCING_LNUM); result = strbuf; break; -- cgit From 1c4b3d41b538078234282cfba74e5cf07c42c916 Mon Sep 17 00:00:00 2001 From: zeertzjq Date: Sun, 12 Mar 2023 10:40:27 +0800 Subject: fix(sleep): correct cursor placement (#22639) Just setcursor_mayforce(true) is enough as Nvim uses msg_grid. --- src/nvim/ex_docmd.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f460b4b93f..49f6d24c89 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5666,10 +5666,7 @@ static void ex_equal(exarg_T *eap) static void ex_sleep(exarg_T *eap) { if (cursor_valid()) { - int n = curwin->w_winrow + curwin->w_wrow - msg_scrolled; - if (n >= 0) { - ui_cursor_goto(n, curwin->w_wincol + curwin->w_wcol); - } + setcursor_mayforce(true); } long len = eap->line2; -- cgit From d6ecead36406233cc56353dd05f3380f0497630f Mon Sep 17 00:00:00 2001 From: bfredl Date: Tue, 14 Mar 2023 11:49:46 +0100 Subject: refactor(screen): screen.c delenda est drawscreen.c vs screen.c makes absolutely no sense. The screen exists only to draw upon it, therefore helper functions are distributed randomly between screen.c and the file that does the redrawing. In addition screen.c does a lot of drawing on the screen. It made more sense for vim/vim as our grid.c is their screen.c Not sure if we want to dump all the code for option chars into optionstr.c, so keep these in a optionchar.c for now. --- src/nvim/ex_docmd.c | 1 - 1 file changed, 1 deletion(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 49f6d24c89..061a8e699e 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -72,7 +72,6 @@ #include "nvim/quickfix.h" #include "nvim/regexp.h" #include "nvim/runtime.h" -#include "nvim/screen.h" #include "nvim/search.h" #include "nvim/shada.h" #include "nvim/state.h" -- cgit From e1db0e35e4d5859b96e6aff882df62d6c714b569 Mon Sep 17 00:00:00 2001 From: Lewis Russell Date: Wed, 15 Mar 2023 23:30:14 +0000 Subject: feat(api): add filetype option nvim_get_option_value - Also adjust the expr-mapping behaviour so normal commands and text changes are allowed in internal dummy buffers. --- src/nvim/ex_docmd.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 061a8e699e..7b94e3184b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -6326,6 +6326,11 @@ void restore_current_state(save_state_T *sst) ui_cursor_shape(); // may show different cursor shape } +bool expr_map_locked(void) +{ + return expr_map_lock > 0 && !(curbuf->b_flags & BF_DUMMY); +} + /// ":normal[!] {commands}": Execute normal mode commands. static void ex_normal(exarg_T *eap) { @@ -6335,10 +6340,11 @@ static void ex_normal(exarg_T *eap) } char *arg = NULL; - if (ex_normal_lock > 0) { + if (expr_map_locked()) { emsg(_(e_secure)); return; } + if (ex_normal_busy >= p_mmd) { emsg(_("E192: Recursive use of :normal too deep")); return; -- cgit From a92b38934a2d00c13ee4d1969d994da15e0857ab Mon Sep 17 00:00:00 2001 From: bfredl Date: Mon, 20 Mar 2023 21:11:10 +0100 Subject: feat(lua): allow `:=expr` as a shorter version of `:lua =expr` existing behavior of := and :[range]= are unchanged. `|` is still allowed with this usage. However, :=p and similar are changed in a way which could be construed as a breaking change. Allowing |ex-flags| for := in the first place was a mistake as any form of := DOES NOT MOVE THE CURSOR. So it would print one line number and then print a completely different line contents after that. --- src/nvim/ex_docmd.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 7b94e3184b..6a259b75fb 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -5658,8 +5658,13 @@ static void ex_pwd(exarg_T *eap) /// ":=". static void ex_equal(exarg_T *eap) { - smsg("%" PRId64, (int64_t)eap->line2); - ex_may_print(eap); + if (*eap->arg != NUL && *eap->arg != '|') { + // equivalent to :lua= expr + ex_lua(eap); + } else { + eap->nextcmd = find_nextcmd(eap->arg); + smsg("%" PRId64, (int64_t)eap->line2); + } } static void ex_sleep(exarg_T *eap) -- cgit From 371823d407d7d7519735131bcad4670c62a731a7 Mon Sep 17 00:00:00 2001 From: ii14 <59243201+ii14@users.noreply.github.com> Date: Wed, 5 Apr 2023 21:13:53 +0200 Subject: refactor: make error message definitions const message.c functions now take const char * as a format. Error message definitions can be made const. --- src/nvim/ex_docmd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/nvim/ex_docmd.c') diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index 6a259b75fb..bc8c7eead0 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -85,15 +85,15 @@ #include "nvim/vim.h" #include "nvim/window.h" -static char e_ambiguous_use_of_user_defined_command[] +static const char e_ambiguous_use_of_user_defined_command[] = N_("E464: Ambiguous use of user-defined command"); -static char e_not_an_editor_command[] +static const char e_not_an_editor_command[] = N_("E492: Not an editor command"); -static char e_no_source_file_name_to_substitute_for_sfile[] +static const char e_no_source_file_name_to_substitute_for_sfile[] = N_("E498: no :source file name to substitute for \"\""); -static char e_no_call_stack_to_substitute_for_stack[] +static const char e_no_call_stack_to_substitute_for_stack[] = N_("E489: no call stack to substitute for \"\""); -static char e_no_script_file_name_to_substitute_for_script[] +static const char e_no_script_file_name_to_substitute_for_script[] = N_("E1274: No script file name to substitute for \"