aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSean Dewar <6256228+seandewar@users.noreply.github.com>2024-03-12 23:05:09 +0000
committerGitHub <noreply@github.com>2024-03-12 23:05:09 +0000
commit9f59415243adcf70c02bc056ed755859456b20e8 (patch)
tree638f689b5225eb4e63c30b2cf15fb549e0780183 /src
parentdc7ccd6bca81dfa6ade6462a6e30770c63d48266 (diff)
parentc048beef6c034a46e324fcea7210082d48db32ee (diff)
downloadrneovim-9f59415243adcf70c02bc056ed755859456b20e8.tar.gz
rneovim-9f59415243adcf70c02bc056ed755859456b20e8.tar.bz2
rneovim-9f59415243adcf70c02bc056ed755859456b20e8.zip
Merge pull request #27839 from seandewar/vim-9.1.0169
vim-patch:9.1.{0169,0170,0171,9a660d2883f9}
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval.lua5
-rw-r--r--src/nvim/eval/window.c26
-rw-r--r--src/nvim/globals.h2
-rw-r--r--src/nvim/window.c13
4 files changed, 19 insertions, 27 deletions
diff --git a/src/nvim/eval.lua b/src/nvim/eval.lua
index febd022254..96dc32259f 100644
--- a/src/nvim/eval.lua
+++ b/src/nvim/eval.lua
@@ -8746,6 +8746,7 @@ M.funcs = {
When a match has been found its line number is returned.
If there is no match a 0 is returned and the cursor doesn't
move. No error message is given.
+ To get the matched string, use |matchbufline()|.
{flags} is a String, which can contain these character flags:
'b' search Backward instead of forward
@@ -12856,7 +12857,9 @@ M.funcs = {
# the number of the last accessed window (where
|CTRL-W_p| goes to). If there is no previous
window or it is in another tab page 0 is
- returned.
+ returned. May refer to the current window in
+ some cases (e.g. when evaluating 'statusline'
+ expressions).
{N}j the number of the Nth window below the
current window (where |CTRL-W_j| goes to).
{N}k the number of the Nth window above the current
diff --git a/src/nvim/eval/window.c b/src/nvim/eval/window.c
index e54f46dcc3..3e2f6301ca 100644
--- a/src/nvim/eval/window.c
+++ b/src/nvim/eval/window.c
@@ -701,8 +701,8 @@ void f_win_splitmove(typval_T *argvars, typval_T *rettv, EvalFuncData fptr)
size = (int)tv_dict_get_number(d, "size");
}
- // Check if we can split the target before we bother switching windows.
- if (is_aucmd_win(wp) || text_or_buf_locked() || check_split_disallowed(targetwin) == FAIL) {
+ // Check if we're allowed to continue before we bother switching windows.
+ if (is_aucmd_win(wp) || text_or_buf_locked() || check_split_disallowed(wp) == FAIL) {
return;
}
@@ -956,13 +956,8 @@ int switch_win_noblock(switchwin_T *switchwin, win_T *win, tabpage_T *tp, bool n
if (tp != NULL) {
switchwin->sw_curtab = curtab;
if (no_display) {
- curtab->tp_firstwin = firstwin;
- curtab->tp_lastwin = lastwin;
- curtab->tp_topframe = topframe;
- curtab = tp;
- firstwin = curtab->tp_firstwin;
- lastwin = curtab->tp_lastwin;
- topframe = curtab->tp_topframe;
+ unuse_tabpage(curtab);
+ use_tabpage(tp);
} else {
goto_tabpage_tp(tp, false, false);
}
@@ -989,13 +984,12 @@ void restore_win_noblock(switchwin_T *switchwin, bool no_display)
{
if (switchwin->sw_curtab != NULL && valid_tabpage(switchwin->sw_curtab)) {
if (no_display) {
- curtab->tp_firstwin = firstwin;
- curtab->tp_lastwin = lastwin;
- curtab->tp_topframe = topframe;
- curtab = switchwin->sw_curtab;
- firstwin = curtab->tp_firstwin;
- lastwin = curtab->tp_lastwin;
- topframe = curtab->tp_topframe;
+ win_T *const old_tp_curwin = curtab->tp_curwin;
+
+ unuse_tabpage(curtab);
+ // Don't change the curwin of the tabpage we temporarily visited.
+ curtab->tp_curwin = old_tp_curwin;
+ use_tabpage(switchwin->sw_curtab);
} else {
goto_tabpage_tp(switchwin->sw_curtab, false, false);
}
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index aecb9d1116..06fb95b577 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -363,7 +363,7 @@ EXTERN bool sys_menu INIT( = false);
// currently active window.
EXTERN win_T *firstwin; // first window
EXTERN win_T *lastwin; // last window
-EXTERN win_T *prevwin INIT( = NULL); // previous window
+EXTERN win_T *prevwin INIT( = NULL); // previous window (may equal curwin)
#define ONE_WINDOW (firstwin == lastwin)
#define FOR_ALL_FRAMES(frp, first_frame) \
for ((frp) = first_frame; (frp) != NULL; (frp) = (frp)->fr_next)
diff --git a/src/nvim/window.c b/src/nvim/window.c
index 521699f2f0..9468207d41 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -939,7 +939,7 @@ void ui_ext_win_viewport(win_T *wp)
}
}
-/// If "split_disallowed" is set or "wp"s buffer is closing, give an error and return FAIL.
+/// If "split_disallowed" is set, or "wp"'s buffer is closing, give an error and return FAIL.
/// Otherwise return OK.
int check_split_disallowed(const win_T *wp)
FUNC_ATTR_NONNULL_ALL
@@ -1966,13 +1966,12 @@ int win_splitmove(win_T *wp, int size, int flags)
// Split a window on the desired side and put "wp" there.
if (win_split_ins(size, flags, wp, dir, unflat_altfr) == NULL) {
- win_append(wp->w_prev, wp, NULL);
if (!wp->w_floating) {
// win_split_ins doesn't change sizes or layout if it fails to insert an
// existing window, so just undo winframe_remove.
winframe_restore(wp, dir, unflat_altfr);
- win_comp_pos(); // recompute window positions
}
+ win_append(wp->w_prev, wp, NULL);
return FAIL;
}
@@ -3271,7 +3270,6 @@ win_T *winframe_find_altwin(win_T *win, int *dirp, tabpage_T *tp, frame_T **altf
/// Flatten "frp" into its parent frame if it's the only child, also merging its
/// list with the grandparent if they share the same layout.
/// Frees "frp" if flattened; also "frp->fr_parent" if it has the same layout.
-/// "frp" must be valid in the current tabpage.
static void frame_flatten(frame_T *frp)
FUNC_ATTR_NONNULL_ALL
{
@@ -3359,7 +3357,8 @@ void winframe_restore(win_T *wp, int dir, frame_T *unflat_altfr)
int row = wp->w_winrow;
int col = wp->w_wincol;
- // Restore the lost room that was redistributed to the altframe.
+ // Restore the lost room that was redistributed to the altframe. Also
+ // adjusts window sizes to fit restored statuslines/separators, if needed.
if (dir == 'v') {
frame_new_height(unflat_altfr, unflat_altfr->fr_height - frp->fr_height,
unflat_altfr == frp->fr_next, false);
@@ -4915,14 +4914,10 @@ static void win_enter_ext(win_T *const wp, const int flags)
if (wp->w_buffer != curbuf) {
buf_copy_options(wp->w_buffer, BCO_ENTER | BCO_NOHELP);
}
-
if (!curwin_invalid) {
prevwin = curwin; // remember for CTRL-W p
curwin->w_redr_status = true;
- } else if (wp == prevwin) {
- prevwin = NULL; // don't want it to be the new curwin
}
-
curwin = wp;
curbuf = wp->w_buffer;