aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRob Pilling <robpilling@gmail.com>2019-10-29 22:31:06 +0000
committerRob Pilling <robpilling@gmail.com>2019-10-31 19:16:52 +0000
commit1f6ce1f97d60f9fd1cc75dab4b604a72d390bf1e (patch)
treeb5d4cc61d23ac3c7a82e20960144d480a2ef853e
parent1c7aa1131297b4b3686d66aae06090e1398da56c (diff)
downloadrneovim-1f6ce1f97d60f9fd1cc75dab4b604a72d390bf1e.tar.gz
rneovim-1f6ce1f97d60f9fd1cc75dab4b604a72d390bf1e.tar.bz2
rneovim-1f6ce1f97d60f9fd1cc75dab4b604a72d390bf1e.zip
Only apply 'icm' substitutions when preview was successfully opened
-rw-r--r--src/nvim/ex_cmds.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 2e8bd79c81..c1ef08593d 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -5563,7 +5563,12 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr,
linenr_T highest_num_line = 0;
int col_width = 0;
+ // if we fail to split the window, we don't want to modify orig_buf
+ bool split_success = false;
+
if (split && win_split((int)p_cwh, WSP_BOT) != FAIL) {
+ split_success = true;
+
buf_open_scratch(preview_buf ? bufnr : 0, "[Preview]");
buf_clear();
preview_buf = curbuf;
@@ -5593,7 +5598,7 @@ static buf_T *show_sub(exarg_T *eap, pos_T old_cusr,
for (size_t matchidx = 0; matchidx < lines.subresults.size; matchidx++) {
SubResult match = lines.subresults.items[matchidx];
- if (split && preview_buf) {
+ if (split_success && preview_buf) {
lpos_T p_start = { 0, match.start.col }; // match starts here in preview
lpos_T p_end = { 0, match.end.col }; // ... and ends here