aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vimscript.c27
-rw-r--r--src/nvim/ex_docmd.c17
-rw-r--r--src/nvim/screen.c5
-rw-r--r--src/nvim/search.c25
-rw-r--r--src/nvim/spell.c2
-rw-r--r--src/nvim/strings.c21
6 files changed, 54 insertions, 43 deletions
diff --git a/src/nvim/api/vimscript.c b/src/nvim/api/vimscript.c
index b8f7b33cd5..e71f1a11ec 100644
--- a/src/nvim/api/vimscript.c
+++ b/src/nvim/api/vimscript.c
@@ -1304,20 +1304,23 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
capture_ga = &capture_local;
}
- try_start();
- if (output) {
- msg_silent++;
- }
+ TRY_WRAP({
+ try_start();
+ if (output) {
+ msg_silent++;
+ }
- WITH_SCRIPT_CONTEXT(channel_id, {
- execute_cmd(&ea, &cmdinfo);
- });
+ WITH_SCRIPT_CONTEXT(channel_id, {
+ execute_cmd(&ea, &cmdinfo);
+ });
- if (output) {
- capture_ga = save_capture_ga;
- msg_silent = save_msg_silent;
- }
- try_end(err);
+ if (output) {
+ capture_ga = save_capture_ga;
+ msg_silent = save_msg_silent;
+ }
+
+ try_end(err);
+ });
if (ERROR_SET(err)) {
goto clear_ga;
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 7506c353dd..5f9d73a25a 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -1583,13 +1583,14 @@ bool parse_cmdline(char *cmdline, exarg_T *eap, CmdParseInfo *cmdinfo, char **er
/// @param cmdinfo Command parse information
void execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo)
{
+ char *errormsg = NULL;
+
#define ERROR(msg) \
do { \
- emsg(msg); \
+ errormsg = msg; \
goto end; \
} while (0)
- char *errormsg = NULL;
cmdmod_T save_cmdmod = cmdmod;
cmdmod = cmdinfo->cmdmod;
@@ -1648,7 +1649,7 @@ void execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo)
// If filename expansion is enabled, expand filenames
if (cmdinfo->magic.file) {
if (expand_filename(eap, (char_u **)eap->cmdlinep, &errormsg) == FAIL) {
- ERROR(errormsg);
+ goto end;
}
}
@@ -1706,14 +1707,20 @@ void execute_cmd(exarg_T *eap, CmdParseInfo *cmdinfo)
eap->errmsg = NULL;
(cmdnames[eap->cmdidx].cmd_func)(eap);
if (eap->errmsg != NULL) {
- ERROR(_(eap->errmsg));
+ errormsg = _(eap->errmsg);
}
}
+
end:
+ if (errormsg != NULL && *errormsg != NUL) {
+ emsg(errormsg);
+ }
// Undo command modifiers
undo_cmdmod(eap, msg_scroll);
cmdmod = save_cmdmod;
-
+ if (eap->did_sandbox) {
+ sandbox--;
+ }
#undef ERROR
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index 86dbf532a7..df87955c46 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -5328,6 +5328,11 @@ static void win_redr_custom(win_T *wp, bool draw_winbar, bool draw_ruler)
col = 0;
grid = &wp->w_grid;
grid_adjust(&grid, &row, &col);
+
+ if (row < 0) {
+ return;
+ }
+
fillchar = wp->w_p_fcs_chars.wbr;
attr = (wp == curwin) ? HL_ATTR(HLF_WBR) : HL_ATTR(HLF_WBRNC);
maxwidth = wp->w_width_inner;
diff --git a/src/nvim/search.c b/src/nvim/search.c
index 11d40c058c..c79ce08cd7 100644
--- a/src/nvim/search.c
+++ b/src/nvim/search.c
@@ -204,31 +204,6 @@ char_u *get_search_pat(void)
return mr_pattern;
}
-/*
- * Reverse text into allocated memory.
- * Returns the allocated string.
- *
- * TODO(philix): move reverse_text() to strings.c
- */
-char_u *reverse_text(char_u *s) FUNC_ATTR_NONNULL_RET
-{
- /*
- * Reverse the pattern.
- */
- size_t len = STRLEN(s);
- char_u *rev = xmalloc(len + 1);
- size_t rev_i = len;
- for (size_t s_i = 0; s_i < len; s_i++) {
- const int mb_len = utfc_ptr2len((char *)s + s_i);
- rev_i -= mb_len;
- memmove(rev + rev_i, s + s_i, mb_len);
- s_i += mb_len - 1;
- }
- rev[len] = NUL;
-
- return rev;
-}
-
void save_re_pat(int idx, char_u *pat, int magic)
{
if (spats[idx].pat != pat) {
diff --git a/src/nvim/spell.c b/src/nvim/spell.c
index 1ba29e3fc1..df3ee73a28 100644
--- a/src/nvim/spell.c
+++ b/src/nvim/spell.c
@@ -443,7 +443,7 @@ size_t spell_check(win_T *wp, char_u *ptr, hlf_T *attrp, int *capcol, bool docou
MAXWLEN + 1);
mi.mi_fwordlen = (int)STRLEN(mi.mi_fword);
- if (camel_case) {
+ if (camel_case && mi.mi_fwordlen > 0) {
// introduce a fake word end space into the folded word.
mi.mi_fword[mi.mi_fwordlen - 1] = ' ';
}
diff --git a/src/nvim/strings.c b/src/nvim/strings.c
index 065254da28..999e6801fb 100644
--- a/src/nvim/strings.c
+++ b/src/nvim/strings.c
@@ -1508,3 +1508,24 @@ int kv_do_printf(StringBuilder *str, const char *fmt, ...)
str->size += (size_t)printed;
return printed;
}
+
+/// Reverse text into allocated memory.
+///
+/// @return the allocated string.
+char_u *reverse_text(char_u *s)
+ FUNC_ATTR_NONNULL_RET
+{
+ // Reverse the pattern.
+ size_t len = STRLEN(s);
+ char_u *rev = xmalloc(len + 1);
+ size_t rev_i = len;
+ for (size_t s_i = 0; s_i < len; s_i++) {
+ const int mb_len = utfc_ptr2len((char *)s + s_i);
+ rev_i -= (size_t)mb_len;
+ memmove(rev + rev_i, s + s_i, (size_t)mb_len);
+ s_i += (size_t)mb_len - 1;
+ }
+ rev[len] = NUL;
+
+ return rev;
+}