A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/neovim/neovim/commit/85ae04dbfd405343b10c400d40e95334a44cc978 below:

close floating windows when calling win_close() · neovim/neovim@85ae04d · GitHub

@@ -304,7 +304,7 @@ void do_window(int nchar, long Prenum, int xchar)

304 304

newtab = curtab;

305 305

goto_tabpage_tp(oldtab, true, true);

306 306

if (curwin == wp) {

307 -

win_close(curwin, false);

307 +

win_close(curwin, false, false);

308 308

}

309 309

if (valid_tabpage(newtab)) {

310 310

goto_tabpage_tp(newtab, true, true);

@@ -449,7 +449,7 @@ void do_window(int nchar, long Prenum, int xchar)

449 449

RESET_BINDING(curwin);

450 450

if (do_ecmd(0, ptr, NULL, NULL, ECMD_LASTL, ECMD_HIDE, NULL) == FAIL) {

451 451

// Failed to open the file, close the window opened for it.

452 -

win_close(curwin, false);

452 +

win_close(curwin, false, false);

453 453

goto_tabpage_win(oldtab, oldwin);

454 454

} else if (nchar == 'F' && lnum >= 0) {

455 455

curwin->w_cursor.lnum = lnum;

@@ -2290,7 +2290,7 @@ void close_windows(buf_T *buf, int keep_curwin)

2290 2290

for (win_T *wp = firstwin; wp != NULL && !ONE_WINDOW;) {

2291 2291

if (wp->w_buffer == buf && (!keep_curwin || wp != curwin)

2292 2292

&& !(wp->w_closing || wp->w_buffer->b_locked > 0)) {

2293 -

if (win_close(wp, false) == FAIL) {

2293 +

if (win_close(wp, false, false) == FAIL) {

2294 2294

// If closing the window fails give up, to avoid looping forever.

2295 2295

break;

2296 2296

}

@@ -2368,6 +2368,22 @@ bool last_nonfloat(win_T *wp) FUNC_ATTR_PURE FUNC_ATTR_WARN_UNUSED_RESULT

2368 2368

return wp != NULL && firstwin == wp && !(wp->w_next && !wp->w_floating);

2369 2369

}

2370 2370 2371 +

/// Check if floating windows can be closed.

2372 +

///

2373 +

/// @return true if all floating windows can be closed

2374 +

static bool can_close_floating_windows(tabpage_T *tab)

2375 +

{

2376 +

FOR_ALL_WINDOWS_IN_TAB(wp, tab) {

2377 +

buf_T *buf = wp->w_buffer;

2378 +

int need_hide = (bufIsChanged(buf) && buf->b_nwindows <= 1);

2379 + 2380 +

if (need_hide && !buf_hide(buf)) {

2381 +

return false;

2382 +

}

2383 +

}

2384 +

return true;

2385 +

}

2386 + 2371 2387

/// Close the possibly last window in a tab page.

2372 2388

///

2373 2389

/// @param win window to close

@@ -2432,7 +2448,7 @@ static bool close_last_window_tabpage(win_T *win, bool free_buf, tabpage_T *prev

2432 2448

//

2433 2449

// Called by :quit, :close, :xit, :wq and findtag().

2434 2450

// Returns FAIL when the window was not closed.

2435 -

int win_close(win_T *win, bool free_buf)

2451 +

int win_close(win_T *win, bool free_buf, bool force)

2436 2452

{

2437 2453

win_T *wp;

2438 2454

bool other_buffer = false;

@@ -2462,9 +2478,18 @@ int win_close(win_T *win, bool free_buf)

2462 2478

}

2463 2479

if ((firstwin == win && lastwin_nofloating() == win)

2464 2480

&& lastwin->w_floating) {

2465 -

// TODO(bfredl): we might close the float also instead

2466 -

emsg(e_floatonly);

2467 -

return FAIL;

2481 +

if (force || can_close_floating_windows(curtab)) {

2482 +

win_T *nextwp;

2483 +

for (win_T *wpp = firstwin; wpp != NULL; wpp = nextwp) {

2484 +

nextwp = wpp->w_next;

2485 +

if (wpp->w_floating) {

2486 +

win_close(wpp, free_buf, force);

2487 +

}

2488 +

}

2489 +

} else {

2490 +

emsg(e_floatonly);

2491 +

return FAIL;

2492 +

}

2468 2493

}

2469 2494 2470 2495

// When closing the last window in a tab page first go to another tab page

@@ -3611,7 +3636,9 @@ void close_others(int message, int forceit)

3611 3636

continue;

3612 3637

}

3613 3638

}

3614 -

win_close(wp, !buf_hide(wp->w_buffer) && !bufIsChanged(wp->w_buffer));

3639 +

win_close(wp,

3640 +

!buf_hide(wp->w_buffer) && !bufIsChanged(wp->w_buffer),

3641 +

false);

3615 3642

}

3616 3643 3617 3644

if (message && !ONE_WINDOW) {


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4