A RetroSearch Logo

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

Search Query:

Showing content from https://github.com/neovim/neovim/commit/3fdb7b528d9d066ccce8b1cb5d2225c338acfbb8 below:

handle buffer deletion with floating windows · neovim/neovim@3fdb7b5 · GitHub

@@ -8,6 +8,7 @@ local command, feed_command = helpers.command, helpers.feed_command

8 8

local eval = helpers.eval

9 9

local eq = helpers.eq

10 10

local neq = helpers.neq

11 +

local expect = helpers.expect

11 12

local exec_lua = helpers.exec_lua

12 13

local insert = helpers.insert

13 14

local meths = helpers.meths

@@ -418,40 +419,154 @@ describe('float window', function()

418 419

end)

419 420 420 421

describe('with only one tabpage', function()

422 +

local old_buf, old_win

423 +

local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}

424 +

before_each(function()

425 +

old_buf = meths.get_current_buf()

426 +

old_win = meths.get_current_win()

427 +

end)

421 428

describe('closing the last non-floating window gives E444', function()

422 -

local old_win

423 429

before_each(function()

424 -

old_win = meths.get_current_win()

425 -

meths.open_win(0, true, {relative = 'editor', row = 1, col = 1, width = 1, height = 1})

430 +

meths.open_win(old_buf, true, float_opts)

426 431

end)

427 432

it('if called from non-floating window', function()

428 433

meths.set_current_win(old_win)

429 -

eq('Vim:E444: Cannot close last window', pcall_err(meths.win_close, old_win, false))

434 +

eq('Vim:E444: Cannot close last window',

435 +

pcall_err(meths.win_close, old_win, false))

430 436

end)

431 437

it('if called from floating window', function()

432 -

eq('Vim:E444: Cannot close last window', pcall_err(meths.win_close, old_win, false))

438 +

eq('Vim:E444: Cannot close last window',

439 +

pcall_err(meths.win_close, old_win, false))

440 +

end)

441 +

end)

442 +

describe("deleting the last non-floating window's buffer", function()

443 +

before_each(function()

444 +

insert('foo')

445 +

end)

446 +

describe('when there is only one buffer leaves that window with an empty buffer', function()

447 +

before_each(function()

448 +

meths.open_win(old_buf, true, float_opts)

449 +

end)

450 +

it('if called from non-floating window', function()

451 +

meths.set_current_win(old_win)

452 +

meths.buf_delete(old_buf, {force = true})

453 +

eq(old_win, meths.get_current_win())

454 +

expect('')

455 +

eq(1, #meths.list_wins())

456 +

end)

457 +

it('if called from floating window', function()

458 +

meths.buf_delete(old_buf, {force = true})

459 +

eq(old_win, meths.get_current_win())

460 +

expect('')

461 +

eq(1, #meths.list_wins())

462 +

end)

463 +

end)

464 +

describe('when there are other buffers closes other windows with that buffer', function()

465 +

local other_buf, same_buf_win, other_buf_win

466 +

before_each(function()

467 +

same_buf_win = meths.open_win(old_buf, false, float_opts)

468 +

other_buf = meths.create_buf(true, false)

469 +

other_buf_win = meths.open_win(other_buf, true, float_opts)

470 +

insert('bar')

471 +

meths.set_current_win(old_win)

472 +

end)

473 +

it('if called from non-floating window', function()

474 +

meths.buf_delete(old_buf, {force = true})

475 +

eq(old_win, meths.get_current_win())

476 +

eq(other_buf, meths.get_current_buf())

477 +

expect('bar')

478 +

eq(2, #meths.list_wins())

479 +

end)

480 +

it('if called from floating window with the same buffer', function()

481 +

meths.set_current_win(same_buf_win)

482 +

meths.buf_delete(old_buf, {force = true})

483 +

eq(old_win, meths.get_current_win())

484 +

eq(other_buf, meths.get_current_buf())

485 +

expect('bar')

486 +

eq(2, #meths.list_wins())

487 +

end)

488 +

-- TODO: this case is too hard to deal with

489 +

pending('if called from floating window with another buffer', function()

490 +

meths.set_current_win(other_buf_win)

491 +

meths.buf_delete(old_buf, {force = true})

492 +

end)

433 493

end)

434 494

end)

435 495

end)

436 496 437 497

describe('with multiple tabpages', function()

498 +

local old_tabpage, old_buf, old_win

499 +

local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}

500 +

before_each(function()

501 +

old_tabpage = meths.get_current_tabpage()

502 +

insert('oldtab')

503 +

command('tabnew')

504 +

old_buf = meths.get_current_buf()

505 +

old_win = meths.get_current_win()

506 +

end)

438 507

describe('closing the last non-floating window', function()

439 -

local old_tabpage, old_win

440 -

before_each(function()

441 -

old_tabpage = meths.get_current_tabpage()

442 -

command('tabnew')

443 -

old_win = meths.get_current_win()

444 -

meths.open_win(0, true, {relative = 'editor', row = 1, col = 1, width = 1, height = 1})

445 -

end)

446 508

describe('when all floating windows are closeable closes the tabpage', function()

509 +

before_each(function()

510 +

meths.open_win(old_buf, true, float_opts)

511 +

end)

447 512

it('if called from non-floating window', function()

448 513

meths.set_current_win(old_win)

449 514

meths.win_close(old_win, false)

450 515

eq(old_tabpage, meths.get_current_tabpage())

516 +

expect('oldtab')

517 +

eq(1, #meths.list_tabpages())

451 518

end)

452 519

it('if called from floating window', function()

453 520

meths.win_close(old_win, false)

454 521

eq(old_tabpage, meths.get_current_tabpage())

522 +

expect('oldtab')

523 +

eq(1, #meths.list_tabpages())

524 +

end)

525 +

end)

526 +

describe('when there are non-closeable floating windows gives E5601', function()

527 +

before_each(function()

528 +

command('set nohidden')

529 +

local other_buf = meths.create_buf(true, false)

530 +

meths.open_win(other_buf, true, float_opts)

531 +

insert('foo')

532 +

end)

533 +

it('if called from non-floating window', function()

534 +

meths.set_current_win(old_win)

535 +

eq('Vim:E5601: Cannot close window, only floating window would remain',

536 +

pcall_err(meths.win_close, old_win, false))

537 +

end)

538 +

it('if called from floating window', function()

539 +

eq('Vim:E5601: Cannot close window, only floating window would remain',

540 +

pcall_err(meths.win_close, old_win, false))

541 +

end)

542 +

end)

543 +

end)

544 +

describe("deleting the last non-floating window's buffer", function()

545 +

describe('when all floating windows are closeable closes the tabpage', function()

546 +

local other_buf, same_buf_win, other_buf_win

547 +

before_each(function()

548 +

same_buf_win = meths.open_win(old_buf, false, float_opts)

549 +

other_buf = meths.create_buf(true, false)

550 +

other_buf_win = meths.open_win(other_buf, true, float_opts)

551 +

meths.set_current_win(old_win)

552 +

end)

553 +

it('if called from non-floating window', function()

554 +

meths.buf_delete(old_buf, {force = false})

555 +

eq(old_tabpage, meths.get_current_tabpage())

556 +

expect('oldtab')

557 +

eq(1, #meths.list_tabpages())

558 +

end)

559 +

it('if called from floating window with the same buffer', function()

560 +

meths.set_current_win(same_buf_win)

561 +

meths.buf_delete(old_buf, {force = false})

562 +

eq(old_tabpage, meths.get_current_tabpage())

563 +

expect('oldtab')

564 +

eq(1, #meths.list_tabpages())

565 +

end)

566 +

-- TODO: this case is too hard to deal with

567 +

pending('if called from floating window with another buffer', function()

568 +

meths.set_current_win(other_buf_win)

569 +

meths.buf_delete(old_buf, {force = false})

455 570

end)

456 571

end)

457 572

end)


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