aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/nvim/ex_docmd.c1
-rw-r--r--src/nvim/getchar.c15
-rw-r--r--src/nvim/getchar.h2
3 files changed, 6 insertions, 12 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 491f7d671e..a6ef533fbd 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -7380,6 +7380,7 @@ static void ex_normal(exarg_T *eap)
* ends with half a command.
*/
save_typeahead(&tabuf);
+ // TODO(philix): after save_typeahead() this is always TRUE
if (tabuf.typebuf_valid) {
/*
* Repeat the :normal command for each line in the range. When no
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index d8e415c845..cc9f65fe29 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -1142,7 +1142,7 @@ static void may_sync_undo(void)
/*
* Make "typebuf" empty and allocate new buffers.
*/
-int alloc_typebuf(void)
+void alloc_typebuf(void)
{
typebuf.tb_buf = xmalloc(TYPELEN_INIT);
typebuf.tb_noremap = xmalloc(TYPELEN_INIT);
@@ -1154,7 +1154,6 @@ int alloc_typebuf(void)
typebuf.tb_no_abbr_cnt = 0;
if (++typebuf.tb_change_cnt == 0)
typebuf.tb_change_cnt = 1;
- return OK;
}
/*
@@ -1182,11 +1181,7 @@ int save_typebuf(void)
{
init_typebuf();
saved_typebuf[curscript] = typebuf;
- /* If out of memory: restore typebuf and close file. */
- if (alloc_typebuf() == FAIL) {
- closescript();
- return FAIL;
- }
+ alloc_typebuf();
return OK;
}
@@ -1202,10 +1197,8 @@ static int old_mouse_col; /* mouse_col related to old_char */
void save_typeahead(tasave_T *tp)
{
tp->save_typebuf = typebuf;
- tp->typebuf_valid = (alloc_typebuf() == OK);
- if (!tp->typebuf_valid)
- typebuf = tp->save_typebuf;
-
+ alloc_typebuf();
+ tp->typebuf_valid = TRUE;
tp->old_char = old_char;
tp->old_mod_mask = old_mod_mask;
old_char = -1;
diff --git a/src/nvim/getchar.h b/src/nvim/getchar.h
index 527573bdab..edb008bd76 100644
--- a/src/nvim/getchar.h
+++ b/src/nvim/getchar.h
@@ -31,7 +31,7 @@ int typebuf_changed(int tb_change_cnt);
int typebuf_typed(void);
int typebuf_maplen(void);
void del_typebuf(int len, int offset);
-int alloc_typebuf(void);
+void alloc_typebuf(void);
void free_typebuf(void);
int save_typebuf(void);
void save_typeahead(tasave_T *tp);