aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/api/vim.c15
-rw-r--r--src/nvim/decoration.c3
-rw-r--r--src/nvim/eval.lua4
-rw-r--r--src/nvim/event/libuv_process.c2
-rw-r--r--src/nvim/ex_cmds2.c20
-rw-r--r--src/nvim/math.c2
-rw-r--r--src/nvim/message.c10
-rw-r--r--src/nvim/os/input.c7
-rw-r--r--src/nvim/textformat.c23
-rw-r--r--src/nvim/ui.c2
-rw-r--r--src/nvim/version.c2
11 files changed, 54 insertions, 36 deletions
diff --git a/src/nvim/api/vim.c b/src/nvim/api/vim.c
index 2fb8f3d554..82e9ddff2d 100644
--- a/src/nvim/api/vim.c
+++ b/src/nvim/api/vim.c
@@ -277,6 +277,7 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks)
bool typed = false;
bool execute = false;
bool dangerous = false;
+ bool lowlevel = false;
for (size_t i = 0; i < mode.size; i++) {
switch (mode.data[i]) {
@@ -292,6 +293,8 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks)
execute = true; break;
case '!':
dangerous = true; break;
+ case 'L':
+ lowlevel = true; break;
}
}
@@ -307,10 +310,14 @@ void nvim_feedkeys(String keys, String mode, Boolean escape_ks)
} else {
keys_esc = keys.data;
}
- ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
- insert ? 0 : typebuf.tb_len, !typed, false);
- if (vgetc_busy) {
- typebuf_was_filled = true;
+ if (lowlevel) {
+ input_enqueue_raw(cstr_as_string(keys_esc));
+ } else {
+ ins_typebuf(keys_esc, (remap ? REMAP_YES : REMAP_NONE),
+ insert ? 0 : typebuf.tb_len, !typed, false);
+ if (vgetc_busy) {
+ typebuf_was_filled = true;
+ }
}
if (escape_ks) {
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 41ef1aceaf..716f3d19b9 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -792,12 +792,11 @@ static const uint32_t signtext_filter[4] = {[kMTMetaSignText] = kMTFilterSelect
/// @param clear kFalse, kTrue or kNone for an, added/deleted, cleared, or initialized range.
void buf_signcols_count_range(buf_T *buf, int row1, int row2, int add, TriState clear)
{
- if (!buf->b_signcols.autom || !buf_meta_total(buf, kMTMetaSignText)) {
+ if (!buf->b_signcols.autom || row2 < row1 || !buf_meta_total(buf, kMTMetaSignText)) {
return;
}
// Allocate an array of integers holding the number of signs in the range.
- assert(row2 >= row1);
int *count = xcalloc(sizeof(int), (size_t)(row2 + 1 - row1));
MarkTreeIter itr[1];
MTPair pair = { 0 };
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index 6a3eabc467..d2137da48d 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -2071,14 +2071,13 @@ M.funcs = {
The result is a Number:
1 exists
0 does not exist
- -1 not implemented on this system
|exepath()| can be used to get the full path of an executable.
]=],
fast = true,
name = 'executable',
params = { { 'expr', 'any' } },
- returns = '0|1|-1',
+ returns = '0|1',
signature = 'executable({expr})',
},
execute = {
@@ -2481,6 +2480,7 @@ M.funcs = {
't' Handle keys as if typed; otherwise they are handled as
if coming from a mapping. This matters for undo,
opening folds, etc.
+ 'L' Lowlevel input. Other flags are not used.
'i' Insert the string instead of appending (see above).
'x' Execute commands until typeahead is empty. This is
similar to using ":normal!". You can call feedkeys()
diff --git a/src/nvim/event/libuv_process.c b/src/nvim/event/libuv_process.c
index 608aeb4c15..f77d686c10 100644
--- a/src/nvim/event/libuv_process.c
+++ b/src/nvim/event/libuv_process.c
@@ -90,7 +90,7 @@ int libuv_process_spawn(LibuvProcess *uvproc)
int status;
if ((status = uv_spawn(&proc->loop->uv, &uvproc->uv, &uvproc->uvopts))) {
- DLOG("uv_spawn(%s) failed: %s", uvproc->uvopts.file, uv_strerror(status));
+ ILOG("uv_spawn(%s) failed: %s", uvproc->uvopts.file, uv_strerror(status));
if (uvproc->uvopts.env) {
os_free_fullenv(uvproc->uvopts.env);
}
diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c
index d754150089..b7f4f269e1 100644
--- a/src/nvim/ex_cmds2.c
+++ b/src/nvim/ex_cmds2.c
@@ -212,10 +212,24 @@ void dialog_changed(buf_T *buf, bool checkall)
}
if (ret == VIM_YES) {
- if (buf->b_fname != NULL
- && check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, false) == OK) {
+ bool empty_bufname = buf->b_fname == NULL;
+ if (empty_bufname) {
+ buf_set_name(buf->b_fnum, "Untitled");
+ }
+
+ if (check_overwrite(&ea, buf, buf->b_fname, buf->b_ffname, false) == OK) {
// didn't hit Cancel
- buf_write_all(buf, false);
+ if (buf_write_all(buf, false) == OK) {
+ return;
+ }
+ }
+
+ // restore to empty when write failed
+ if (empty_bufname) {
+ XFREE_CLEAR(buf->b_fname);
+ XFREE_CLEAR(buf->b_ffname);
+ XFREE_CLEAR(buf->b_sfname);
+ unchanged(buf, true, false);
}
} else if (ret == VIM_NO) {
unchanged(buf, true, false);
diff --git a/src/nvim/math.c b/src/nvim/math.c
index 39d166bb53..2fd9cd6ce7 100644
--- a/src/nvim/math.c
+++ b/src/nvim/math.c
@@ -56,7 +56,7 @@ int xctz(uint64_t x)
// Use compiler builtin if possible.
#if defined(__clang__) || (defined(__GNUC__) && (__GNUC__ >= 4))
return __builtin_ctzll(x);
-#elif defined(_MSC_VER)
+#elif defined(HAVE_BITSCANFORWARD64)
unsigned long index;
_BitScanForward64(&index, x);
return (int)index;
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 68a8b8e88b..362dc2c05a 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -3395,9 +3395,7 @@ int do_dialog(int type, const char *title, const char *message, const char *butt
int retval = 0;
int i;
- if (silent_mode // No dialogs in silent mode ("ex -s")
- || !ui_active() // Without a UI Nvim waits for input forever.
- ) {
+ if (silent_mode) { // No dialogs in silent mode ("ex -s")
return dfltbutton; // return default option
}
@@ -3414,6 +3412,12 @@ int do_dialog(int type, const char *title, const char *message, const char *butt
char *hotkeys = msg_show_console_dialog(message, buttons, dfltbutton);
while (true) {
+ // Without a UI Nvim waits for input forever.
+ if (!ui_active() && !input_available()) {
+ retval = dfltbutton;
+ break;
+ }
+
// Get a typed character directly from the user.
int c = get_keystroke(NULL);
switch (c) {
diff --git a/src/nvim/os/input.c b/src/nvim/os/input.c
index 5218e50df6..60b5b48745 100644
--- a/src/nvim/os/input.c
+++ b/src/nvim/os/input.c
@@ -247,6 +247,13 @@ bool os_isatty(int fd)
return uv_guess_handle(fd) == UV_TTY;
}
+void input_enqueue_raw(String keys)
+{
+ if (keys.size > 0) {
+ rbuffer_write(input_buffer, keys.data, keys.size);
+ }
+}
+
size_t input_enqueue(String keys)
{
const char *ptr = keys.data;
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c
index c427206764..1722bcc968 100644
--- a/src/nvim/textformat.c
+++ b/src/nvim/textformat.c
@@ -105,14 +105,9 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
colnr_T col;
bool did_do_comment = false;
- // Cursor is currently at the end of line. No need to format
- // if line length is less than textwidth (8 * textwidth for
- // utf safety)
- if (curwin->w_cursor.col < 8 * textwidth) {
- colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor());
- if (virtcol <= (colnr_T)textwidth) {
- break;
- }
+ colnr_T virtcol = get_nolist_virtcol() + char2cells(c != NUL ? c : gchar_cursor());
+ if (virtcol <= (colnr_T)textwidth) {
+ break;
}
if (no_leader) {
@@ -160,16 +155,9 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
coladvance(curwin, (colnr_T)textwidth);
wantcol = curwin->w_cursor.col;
- // If startcol is large (a long line), formatting takes too much
- // time. The algorithm is O(n^2), it walks from the end of the
- // line to textwidth border every time for each line break.
- //
- // Ceil to 8 * textwidth to optimize.
- curwin->w_cursor.col = startcol < 8 * textwidth ? startcol : 8 * textwidth;
-
+ curwin->w_cursor.col = startcol;
foundcol = 0;
int skip_pos = 0;
- bool first_pass = true;
// Find position to break at.
// Stop at first entered white when 'formatoptions' has 'v'
@@ -177,9 +165,8 @@ void internal_format(int textwidth, int second_indent, int flags, bool format_on
|| (flags & INSCHAR_FORMAT)
|| curwin->w_cursor.lnum != Insstart.lnum
|| curwin->w_cursor.col >= Insstart.col) {
- if (first_pass && c != NUL) {
+ if (curwin->w_cursor.col == startcol && c != NUL) {
cc = c;
- first_pass = false;
} else {
cc = gchar_cursor();
}
diff --git a/src/nvim/ui.c b/src/nvim/ui.c
index 506bb93f5b..98751c8952 100644
--- a/src/nvim/ui.c
+++ b/src/nvim/ui.c
@@ -723,7 +723,7 @@ void ui_call_event(char *name, Array args)
handled = true;
}
if (ERROR_SET(&err)) {
- ELOG("Error while executing ui_comp_event callback: %s", err.msg);
+ ELOG("Error executing UI event callback: %s", err.msg);
}
api_clear_error(&err);
})
diff --git a/src/nvim/version.c b/src/nvim/version.c
index 5443371ba7..c392362bf4 100644
--- a/src/nvim/version.c
+++ b/src/nvim/version.c
@@ -1667,7 +1667,7 @@ static const int included_patches[] = {
818,
817,
816,
- // 815,
+ 815,
814,
813,
812,