diff options
author | Justin M. Keyes <justinkz@gmail.com> | 2018-01-20 16:33:43 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-01-20 16:33:43 +0100 |
commit | ee84da358c27b9c0a6bbd49424bc9d04bb98d662 (patch) | |
tree | f1dc827adfa6d7e3cc6f766657708238ac4b3b0b /src | |
parent | 6a826fce91206e1237e0a5822a67cfd772f524dd (diff) | |
parent | 5a96a9eba238b51e2e90f87a0a9338da363e9e28 (diff) | |
download | rneovim-ee84da358c27b9c0a6bbd49424bc9d04bb98d662.tar.gz rneovim-ee84da358c27b9c0a6bbd49424bc9d04bb98d662.tar.bz2 rneovim-ee84da358c27b9c0a6bbd49424bc9d04bb98d662.zip |
Merge #7878 from justinmk/keymap-leak
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/buffer.c | 1 | ||||
-rw-r--r-- | src/nvim/digraph.c | 17 | ||||
-rw-r--r-- | src/nvim/indent_c.c | 3 | ||||
-rw-r--r-- | src/nvim/testdir/Makefile | 3 | ||||
-rw-r--r-- | src/nvim/testdir/test_cindent.vim | 16 |
5 files changed, 35 insertions, 5 deletions
diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index 21830539f5..6f0c78fde4 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1775,6 +1775,7 @@ void free_buf_options(buf_T *buf, int free_p_ff) clear_string_option(&buf->b_p_flp); clear_string_option(&buf->b_p_isk); clear_string_option(&buf->b_p_keymap); + keymap_ga_clear(&buf->b_kmap_ga); ga_clear(&buf->b_kmap_ga); clear_string_option(&buf->b_p_com); clear_string_option(&buf->b_p_cms); diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index dbcc8db109..bc4c12e0b7 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1841,6 +1841,16 @@ void ex_loadkeymap(exarg_T *eap) status_redraw_curbuf(); } +/// Frees the buf_T.b_kmap_ga field of a buffer. +void keymap_ga_clear(garray_T *kmap_ga) +{ + kmap_T *kp = (kmap_T *)kmap_ga->ga_data; + for (int i = 0; i < kmap_ga->ga_len; i++) { + xfree(kp[i].from); + xfree(kp[i].to); + } +} + /// Stop using 'keymap'. static void keymap_unload(void) { @@ -1858,12 +1868,11 @@ static void keymap_unload(void) // clear the ":lmap"s kp = (kmap_T *)curbuf->b_kmap_ga.ga_data; - for (int i = 0; i < curbuf->b_kmap_ga.ga_len; ++i) { + for (int i = 0; i < curbuf->b_kmap_ga.ga_len; i++) { vim_snprintf((char *)buf, sizeof(buf), "<buffer> %s", kp[i].from); - (void)do_map(1, buf, LANGMAP, FALSE); - xfree(kp[i].from); - xfree(kp[i].to); + (void)do_map(1, buf, LANGMAP, false); } + keymap_ga_clear(&curbuf->b_kmap_ga); p_cpo = save_cpo; diff --git a/src/nvim/indent_c.c b/src/nvim/indent_c.c index 279d45bb0a..53364c0fc5 100644 --- a/src/nvim/indent_c.c +++ b/src/nvim/indent_c.c @@ -1619,6 +1619,9 @@ void parse_cino(buf_T *buf) * while(). */ buf->b_ind_if_for_while = 0; + // indentation for # comments + buf->b_ind_hash_comment = 0; + for (p = buf->b_p_cino; *p; ) { l = p++; if (*p == '-') diff --git a/src/nvim/testdir/Makefile b/src/nvim/testdir/Makefile index c1e6eedf94..18f0bac3cf 100644 --- a/src/nvim/testdir/Makefile +++ b/src/nvim/testdir/Makefile @@ -40,11 +40,12 @@ SCRIPTS ?= $(SCRIPTS_DEFAULT) # Tests using runtest.vim. # Keep test_alot*.res as the last one, sort the others. NEW_TESTS ?= \ - test_arabic.vim \ + test_arabic.res \ test_autocmd.res \ test_bufwintabinfo.res \ test_changedtick.res \ test_charsearch.res \ + test_cindent.res \ test_cmdline.res \ test_command_count.res \ test_cscope.res \ diff --git a/src/nvim/testdir/test_cindent.vim b/src/nvim/testdir/test_cindent.vim new file mode 100644 index 0000000000..5685c2be66 --- /dev/null +++ b/src/nvim/testdir/test_cindent.vim @@ -0,0 +1,16 @@ +" Test for cinoptions and cindent +" +" TODO: rewrite test3.in into this new style test + +func Test_cino_hash() + " Test that curbuf->b_ind_hash_comment is correctly reset + new + setlocal cindent cinoptions=#1 + setlocal cinoptions= + call setline(1, ["#include <iostream>"]) + call cursor(1, 1) + norm! o#include + "call feedkeys("o#include\<esc>", 't') + call assert_equal(["#include <iostream>", "#include"], getline(1,2)) + bwipe! +endfunc |