A RetroSearch Logo

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

Search Query:

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

do not switch window before deleting last listed buffer (… · neovim/neovim@a72f338 · GitHub

@@ -17,6 +17,7 @@ local funcs = helpers.funcs

17 17

local run = helpers.run

18 18

local pcall_err = helpers.pcall_err

19 19

local tbl_contains = global_helpers.tbl_contains

20 +

local curbuf, curwin, curtab = helpers.curbuf, helpers.curwin, helpers.curtab

20 21 21 22

describe('float window', function()

22 23

before_each(function()

@@ -423,8 +424,8 @@ describe('float window', function()

423 424

local old_buf, old_win

424 425

before_each(function()

425 426

insert('foo')

426 -

old_buf = meths.get_current_buf()

427 -

old_win = meths.get_current_win()

427 +

old_buf = curbuf().id

428 +

old_win = curwin().id

428 429

end)

429 430

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

430 431

before_each(function()

@@ -442,44 +443,53 @@ describe('float window', function()

442 443

end)

443 444

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

444 445

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

446 +

local same_buf_float

445 447

before_each(function()

446 -

meths.open_win(old_buf, true, float_opts)

448 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

447 449

end)

448 450

after_each(function()

449 -

eq(old_win, meths.get_current_win())

451 +

eq(old_win, curwin().id)

450 452

expect('')

451 453

eq(1, #meths.list_wins())

452 454

end)

453 455

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

454 -

meths.set_current_win(old_win)

455 456

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

456 457

end)

457 458

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

459 +

meths.set_current_win(same_buf_float)

460 +

command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')

461 +

command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')

458 462

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

463 +

eq(same_buf_float, eval('g:win_leave'))

464 +

eq(old_win, eval('g:win_enter'))

459 465

end)

460 466

end)

461 467

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

462 468

local same_buf_float, other_buf, other_buf_float

463 469

before_each(function()

464 -

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

465 -

other_buf = meths.create_buf(true, false)

466 -

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

470 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

471 +

other_buf = meths.create_buf(true, false).id

472 +

other_buf_float = meths.open_win(other_buf, true, float_opts).id

467 473

insert('bar')

468 474

meths.set_current_win(old_win)

469 475

end)

470 476

after_each(function()

471 -

eq(other_buf, meths.get_current_buf())

477 +

eq(other_buf, curbuf().id)

472 478

expect('bar')

473 479

eq(2, #meths.list_wins())

474 480

end)

475 481

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

476 482

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

477 -

eq(old_win, meths.get_current_win())

483 +

eq(old_win, curwin().id)

478 484

end)

479 485

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

480 486

meths.set_current_win(same_buf_float)

487 +

command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')

488 +

command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')

481 489

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

482 -

eq(old_win, meths.get_current_win())

490 +

eq(same_buf_float, eval('g:win_leave'))

491 +

eq(old_win, eval('g:win_enter'))

492 +

eq(old_win, curwin().id)

483 493

end)

484 494

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

485 495

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

@@ -490,9 +500,9 @@ describe('float window', function()

490 500

describe('creates an empty buffer when there is only one listed buffer', function()

491 501

local same_buf_float, unlisted_buf_float

492 502

before_each(function()

493 -

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

494 -

local unlisted_buf = meths.create_buf(true, false)

495 -

unlisted_buf_float = meths.open_win(unlisted_buf, true, float_opts)

503 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

504 +

local unlisted_buf = meths.create_buf(true, false).id

505 +

unlisted_buf_float = meths.open_win(unlisted_buf, true, float_opts).id

496 506

insert('unlisted')

497 507

command('set nobuflisted')

498 508

meths.set_current_win(old_win)

@@ -503,12 +513,16 @@ describe('float window', function()

503 513

end)

504 514

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

505 515

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

506 -

eq(old_win, meths.get_current_win())

516 +

eq(old_win, curwin().id)

507 517

end)

508 518

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

509 519

meths.set_current_win(same_buf_float)

520 +

command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')

521 +

command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')

510 522

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

511 -

eq(old_win, meths.get_current_win())

523 +

eq(same_buf_float, eval('g:win_leave'))

524 +

eq(old_win, eval('g:win_enter'))

525 +

eq(old_win, curwin().id)

512 526

end)

513 527

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

514 528

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

@@ -525,20 +539,20 @@ describe('float window', function()

525 539

insert('unlisted')

526 540

command('set nobuflisted')

527 541

meths.set_current_win(old_win)

528 -

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

542 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

529 543

end)

530 544

after_each(function()

531 545

expect('')

532 546

eq(2, #meths.list_wins())

533 547

end)

534 548

it('if called from non-floating window with the deleted buffer', function()

535 549

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

536 -

eq(old_win, meths.get_current_win())

550 +

eq(old_win, curwin().id)

537 551

end)

538 552

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

539 553

meths.set_current_win(same_buf_float)

540 554

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

541 -

eq(same_buf_float, meths.get_current_win())

555 +

eq(same_buf_float, curwin().id)

542 556

end)

543 557

end)

544 558

end)

@@ -550,17 +564,17 @@ describe('float window', function()

550 564

before_each(function()

551 565

insert('unlisted')

552 566

command('set nobuflisted')

553 -

unlisted_buf = meths.get_current_buf()

567 +

unlisted_buf = curbuf().id

554 568

command('tabnew')

555 569

insert('foo')

556 -

old_buf = meths.get_current_buf()

557 -

old_win = meths.get_current_win()

570 +

old_buf = curbuf().id

571 +

old_win = curwin().id

558 572

end)

559 573

describe('without splits, deleting the last listed buffer creates an empty buffer', function()

560 574

local same_buf_float

561 575

before_each(function()

562 576

meths.set_current_win(old_win)

563 -

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

577 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

564 578

end)

565 579

after_each(function()

566 580

expect('')

@@ -569,12 +583,16 @@ describe('float window', function()

569 583

end)

570 584

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

571 585

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

572 -

eq(old_win, meths.get_current_win())

586 +

eq(old_win, curwin().id)

573 587

end)

574 588

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

575 589

meths.set_current_win(same_buf_float)

590 +

command('autocmd WinLeave * let g:win_leave = nvim_get_current_win()')

591 +

command('autocmd WinEnter * let g:win_enter = nvim_get_current_win()')

576 592

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

577 -

eq(old_win, meths.get_current_win())

593 +

eq(same_buf_float, eval('g:win_leave'))

594 +

eq(old_win, eval('g:win_enter'))

595 +

eq(old_win, curwin().id)

578 596

end)

579 597

end)

580 598

describe('with splits, deleting the last listed buffer creates an empty buffer', function()

@@ -583,7 +601,7 @@ describe('float window', function()

583 601

command('botright vsplit')

584 602

meths.set_current_buf(unlisted_buf)

585 603

meths.set_current_win(old_win)

586 -

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

604 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

587 605

end)

588 606

after_each(function()

589 607

expect('')

@@ -592,12 +610,12 @@ describe('float window', function()

592 610

end)

593 611

it('if called from non-floating window with the deleted buffer', function()

594 612

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

595 -

eq(old_win, meths.get_current_win())

613 +

eq(old_win, curwin().id)

596 614

end)

597 615

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

598 616

meths.set_current_win(same_buf_float)

599 617

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

600 -

eq(same_buf_float, meths.get_current_win())

618 +

eq(same_buf_float, curwin().id)

601 619

end)

602 620

end)

603 621

end)

@@ -606,72 +624,75 @@ describe('float window', function()

606 624

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

607 625

local old_tabpage, old_buf, old_win

608 626

before_each(function()

609 -

old_tabpage = meths.get_current_tabpage()

627 +

old_tabpage = curtab().id

610 628

insert('oldtab')

611 629

command('tabnew')

612 -

old_buf = meths.get_current_buf()

613 -

old_win = meths.get_current_win()

630 +

old_buf = curbuf().id

631 +

old_win = curwin().id

614 632

end)

615 633

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

616 634

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

635 +

local same_buf_float

617 636

before_each(function()

618 -

meths.open_win(old_buf, true, float_opts)

637 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

619 638

end)

620 639

after_each(function()

621 -

eq(old_tabpage, meths.get_current_tabpage())

640 +

eq(old_tabpage, curtab().id)

622 641

expect('oldtab')

623 642

eq(1, #meths.list_tabpages())

624 643

end)

625 644

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

626 -

meths.set_current_win(old_win)

627 645

meths.win_close(old_win, false)

628 646

end)

629 647

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

648 +

meths.set_current_win(same_buf_float)

630 649

meths.win_close(old_win, false)

631 650

end)

632 651

end)

633 652

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

653 +

local other_buf_float

634 654

before_each(function()

635 655

command('set nohidden')

636 -

local other_buf = meths.create_buf(true, false)

637 -

meths.open_win(other_buf, true, float_opts)

656 +

local other_buf = meths.create_buf(true, false).id

657 +

other_buf_float = meths.open_win(other_buf, true, float_opts).id

638 658

insert('foo')

659 +

meths.set_current_win(old_win)

639 660

end)

640 661

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

641 -

meths.set_current_win(old_win)

642 662

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

643 663

pcall_err(meths.win_close, old_win, false))

644 664

end)

645 665

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

666 +

meths.set_current_win(other_buf_float)

646 667

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

647 668

pcall_err(meths.win_close, old_win, false))

648 669

end)

649 670

end)

650 671

end)

651 672

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

652 673

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

653 -

local same_buf_win, other_buf, other_buf_win

674 +

local same_buf_float, other_buf, other_buf_float

654 675

before_each(function()

655 -

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

656 -

other_buf = meths.create_buf(true, false)

657 -

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

676 +

same_buf_float = meths.open_win(old_buf, false, float_opts).id

677 +

other_buf = meths.create_buf(true, false).id

678 +

other_buf_float = meths.open_win(other_buf, true, float_opts).id

658 679

meths.set_current_win(old_win)

659 680

end)

660 681

after_each(function()

661 -

eq(old_tabpage, meths.get_current_tabpage())

682 +

eq(old_tabpage, curtab().id)

662 683

expect('oldtab')

663 684

eq(1, #meths.list_tabpages())

664 685

end)

665 686

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

666 687

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

667 688

end)

668 689

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

669 -

meths.set_current_win(same_buf_win)

690 +

meths.set_current_win(same_buf_float)

670 691

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

671 692

end)

672 693

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

673 694

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

674 -

meths.set_current_win(other_buf_win)

695 +

meths.set_current_win(other_buf_float)

675 696

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

676 697

end)

677 698

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