aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-03-12 07:19:30 +0800
committerGitHub <noreply@github.com>2024-03-12 07:19:30 +0800
commit6481da3015fd6cf136e752c9123078223c50d91c (patch)
tree565a2380273bfbabe9f749e015afc4d7ae8a5483 /src
parentcf156377e80232aa904b92e4af29dd6c61952401 (diff)
downloadrneovim-6481da3015fd6cf136e752c9123078223c50d91c.tar.gz
rneovim-6481da3015fd6cf136e752c9123078223c50d91c.tar.bz2
rneovim-6481da3015fd6cf136e752c9123078223c50d91c.zip
vim-patch:9.1.0166: Internal error with blockwise getregion() in another buffer (#27819)
Problem: Internal error with blockwise getregion() in another buffer Solution: Also change curwin->w_buffer when changing curbuf (zeertzjq) closes: vim/vim#14179 https://github.com/vim/vim/commit/5406eb8722bddb6a04876956f9a53c1752994851
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/funcs.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/nvim/eval/funcs.c b/src/nvim/eval/funcs.c
index f37542890b..ab92aa7b34 100644
--- a/src/nvim/eval/funcs.c
+++ b/src/nvim/eval/funcs.c
@@ -2863,16 +2863,10 @@ static void f_getregion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return;
}
- buf_T *const save_curbuf = curbuf;
- buf_T *findbuf = curbuf;
-
- if (fnum1 != 0) {
- findbuf = buflist_findnr(fnum1);
- // buffer not loaded
- if (findbuf == NULL || findbuf->b_ml.ml_mfp == NULL) {
- emsg(_(e_buffer_is_not_loaded));
- return;
- }
+ buf_T *findbuf = fnum1 != 0 ? buflist_findnr(fnum1) : curbuf;
+ if (findbuf == NULL || findbuf->b_ml.ml_mfp == NULL) {
+ emsg(_(e_buffer_is_not_loaded));
+ return;
}
if (p1.lnum < 1 || p1.lnum > findbuf->b_ml.ml_line_count) {
@@ -2892,7 +2886,9 @@ static void f_getregion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
return;
}
+ buf_T *const save_curbuf = curbuf;
curbuf = findbuf;
+ curwin->w_buffer = curbuf;
const TriState save_virtual = virtual_op;
virtual_op = virtual_active();
@@ -2975,10 +2971,8 @@ static void f_getregion(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
tv_list_append_allocated_string(rettv->vval.v_list, akt);
}
- if (curbuf != save_curbuf) {
- curbuf = save_curbuf;
- }
-
+ curbuf = save_curbuf;
+ curwin->w_buffer = curbuf;
virtual_op = save_virtual;
}