@@ -418,10 +418,11 @@ describe('float window', function()
418
418
eq(winids, eval('winids'))
419
419
end)
420
420
421
-
describe('with only one tabpage', function()
422
-
local old_buf, old_win
421
+
describe('with only one tabpage,', function()
423
422
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
423
+
local old_buf, old_win
424
424
before_each(function()
425
+
insert('foo')
425
426
old_buf = meths.get_current_buf()
426
427
old_win = meths.get_current_win()
427
428
end)
@@ -440,92 +441,170 @@ describe('float window', function()
440
441
end)
441
442
end)
442
443
describe("deleting the last non-floating window's buffer", function()
443
-
before_each(function()
444
-
insert('foo')
445
-
end)
446
444
describe('leaves one window with an empty buffer when there is only one buffer', function()
447
445
before_each(function()
448
446
meths.open_win(old_buf, true, float_opts)
449
447
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})
448
+
after_each(function()
453
449
eq(old_win, meths.get_current_win())
454
450
expect('')
455
451
eq(1, #meths.list_wins())
456
452
end)
453
+
it('if called from non-floating window', function()
454
+
meths.set_current_win(old_win)
455
+
meths.buf_delete(old_buf, {force = true})
456
+
end)
457
457
it('if called from floating window', function()
458
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
459
end)
463
460
end)
464
461
describe('closes other windows with that buffer when there are other buffers', function()
465
-
local same_buf_win, other_buf, other_buf_win
462
+
local same_buf_float, other_buf, other_buf_float
466
463
before_each(function()
467
-
same_buf_win = meths.open_win(old_buf, false, float_opts)
464
+
same_buf_float = meths.open_win(old_buf, false, float_opts)
468
465
other_buf = meths.create_buf(true, false)
469
-
other_buf_win = meths.open_win(other_buf, true, float_opts)
466
+
other_buf_float = meths.open_win(other_buf, true, float_opts)
470
467
insert('bar')
471
468
meths.set_current_win(old_win)
472
469
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())
470
+
after_each(function()
476
471
eq(other_buf, meths.get_current_buf())
477
472
expect('bar')
478
473
eq(2, #meths.list_wins())
479
474
end)
475
+
it('if called from non-floating window', function()
476
+
meths.buf_delete(old_buf, {force = true})
477
+
eq(old_win, meths.get_current_win())
478
+
end)
480
479
it('if called from floating window with the same buffer', function()
481
-
meths.set_current_win(same_buf_win)
480
+
meths.set_current_win(same_buf_float)
482
481
meths.buf_delete(old_buf, {force = true})
483
482
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
483
end)
488
484
-- TODO: this case is too hard to deal with
489
485
pending('if called from floating window with another buffer', function()
490
-
meths.set_current_win(other_buf_win)
486
+
meths.set_current_win(other_buf_float)
491
487
meths.buf_delete(old_buf, {force = true})
492
488
end)
493
489
end)
494
-
describe('creates a new buffer when there is only one listed buffer', function()
495
-
local same_buf_win, unlisted_buf, unlisted_buf_win
490
+
describe('creates an empty buffer when there is only one listed buffer', function()
491
+
local same_buf_float, unlisted_buf_float
496
492
before_each(function()
497
-
same_buf_win = meths.open_win(old_buf, false, float_opts)
498
-
unlisted_buf = meths.create_buf(true, false)
499
-
unlisted_buf_win = meths.open_win(unlisted_buf, true, float_opts)
500
-
insert('bar')
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)
496
+
insert('unlisted')
501
497
command('set nobuflisted')
502
498
meths.set_current_win(old_win)
503
499
end)
500
+
after_each(function()
501
+
expect('')
502
+
eq(2, #meths.list_wins())
503
+
end)
504
504
it('if called from non-floating window', function()
505
505
meths.buf_delete(old_buf, {force = true})
506
506
eq(old_win, meths.get_current_win())
507
-
expect('')
508
-
eq(2, #meths.list_wins())
509
507
end)
510
508
it('if called from floating window with the same buffer', function()
511
-
meths.set_current_win(same_buf_win)
509
+
meths.set_current_win(same_buf_float)
512
510
meths.buf_delete(old_buf, {force = true})
513
511
eq(old_win, meths.get_current_win())
514
-
expect('')
515
-
eq(2, #meths.list_wins())
516
512
end)
517
513
-- TODO: this case is too hard to deal with
518
514
pending('if called from floating window with an unlisted buffer', function()
519
-
meths.set_current_win(unlisted_buf_win)
515
+
meths.set_current_win(unlisted_buf_float)
516
+
meths.buf_delete(old_buf, {force = true})
517
+
end)
518
+
end)
519
+
end)
520
+
describe('with splits, deleting the last listed buffer creates an empty buffer', function()
521
+
describe('when a non-floating window has an unlisted buffer', function()
522
+
local same_buf_float
523
+
before_each(function()
524
+
command('botright vnew')
525
+
insert('unlisted')
526
+
command('set nobuflisted')
527
+
meths.set_current_win(old_win)
528
+
same_buf_float = meths.open_win(old_buf, false, float_opts)
529
+
end)
530
+
after_each(function()
531
+
expect('')
532
+
eq(2, #meths.list_wins())
533
+
end)
534
+
it('if called from non-floating window with the deleted buffer', function()
535
+
meths.buf_delete(old_buf, {force = true})
536
+
eq(old_win, meths.get_current_win())
537
+
end)
538
+
it('if called from floating window with the deleted buffer', function()
539
+
meths.set_current_win(same_buf_float)
520
540
meths.buf_delete(old_buf, {force = true})
541
+
eq(same_buf_float, meths.get_current_win())
521
542
end)
522
543
end)
523
544
end)
524
545
end)
525
546
526
-
describe('with multiple tabpages', function()
527
-
local old_tabpage, old_buf, old_win
547
+
describe('with mulitple tabpages but only one listed buffer,', function()
548
+
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
549
+
local unlisted_buf, old_buf, old_win
550
+
before_each(function()
551
+
insert('unlisted')
552
+
command('set nobuflisted')
553
+
unlisted_buf = meths.get_current_buf()
554
+
command('tabnew')
555
+
insert('foo')
556
+
old_buf = meths.get_current_buf()
557
+
old_win = meths.get_current_win()
558
+
end)
559
+
describe('without splits, deleting the last listed buffer creates an empty buffer', function()
560
+
local same_buf_float
561
+
before_each(function()
562
+
meths.set_current_win(old_win)
563
+
same_buf_float = meths.open_win(old_buf, false, float_opts)
564
+
end)
565
+
after_each(function()
566
+
expect('')
567
+
eq(2, #meths.list_wins())
568
+
eq(2, #meths.list_tabpages())
569
+
end)
570
+
it('if called from non-floating window', function()
571
+
meths.buf_delete(old_buf, {force = true})
572
+
eq(old_win, meths.get_current_win())
573
+
end)
574
+
it('if called from floating window with the same buffer', function()
575
+
meths.set_current_win(same_buf_float)
576
+
meths.buf_delete(old_buf, {force = true})
577
+
eq(old_win, meths.get_current_win())
578
+
end)
579
+
end)
580
+
describe('with splits, deleting the last listed buffer creates an empty buffer', function()
581
+
local same_buf_float
582
+
before_each(function()
583
+
command('botright vsplit')
584
+
meths.set_current_buf(unlisted_buf)
585
+
meths.set_current_win(old_win)
586
+
same_buf_float = meths.open_win(old_buf, false, float_opts)
587
+
end)
588
+
after_each(function()
589
+
expect('')
590
+
eq(3, #meths.list_wins())
591
+
eq(2, #meths.list_tabpages())
592
+
end)
593
+
it('if called from non-floating window with the deleted buffer', function()
594
+
meths.buf_delete(old_buf, {force = true})
595
+
eq(old_win, meths.get_current_win())
596
+
end)
597
+
it('if called from floating window with the deleted buffer', function()
598
+
meths.set_current_win(same_buf_float)
599
+
meths.buf_delete(old_buf, {force = true})
600
+
eq(same_buf_float, meths.get_current_win())
601
+
end)
602
+
end)
603
+
end)
604
+
605
+
describe('with multiple tabpages and multiple listed buffers,', function()
528
606
local float_opts = {relative = 'editor', row = 1, col = 1, width = 1, height = 1}
607
+
local old_tabpage, old_buf, old_win
529
608
before_each(function()
530
609
old_tabpage = meths.get_current_tabpage()
531
610
insert('oldtab')
@@ -538,18 +617,17 @@ describe('float window', function()
538
617
before_each(function()
539
618
meths.open_win(old_buf, true, float_opts)
540
619
end)
541
-
it('if called from non-floating window', function()
542
-
meths.set_current_win(old_win)
543
-
meths.win_close(old_win, false)
620
+
after_each(function()
544
621
eq(old_tabpage, meths.get_current_tabpage())
545
622
expect('oldtab')
546
623
eq(1, #meths.list_tabpages())
547
624
end)
625
+
it('if called from non-floating window', function()
626
+
meths.set_current_win(old_win)
627
+
meths.win_close(old_win, false)
628
+
end)
548
629
it('if called from floating window', function()
549
630
meths.win_close(old_win, false)
550
-
eq(old_tabpage, meths.get_current_tabpage())
551
-
expect('oldtab')
552
-
eq(1, #meths.list_tabpages())
553
631
end)
554
632
end)
555
633
describe('gives E5601 when there are non-closeable floating windows', function()
@@ -579,18 +657,17 @@ describe('float window', function()
579
657
other_buf_win = meths.open_win(other_buf, true, float_opts)
580
658
meths.set_current_win(old_win)
581
659
end)
582
-
it('if called from non-floating window', function()
583
-
meths.buf_delete(old_buf, {force = false})
660
+
after_each(function()
584
661
eq(old_tabpage, meths.get_current_tabpage())
585
662
expect('oldtab')
586
663
eq(1, #meths.list_tabpages())
587
664
end)
665
+
it('if called from non-floating window', function()
666
+
meths.buf_delete(old_buf, {force = false})
667
+
end)
588
668
it('if called from floating window with the same buffer', function()
589
669
meths.set_current_win(same_buf_win)
590
670
meths.buf_delete(old_buf, {force = false})
591
-
eq(old_tabpage, meths.get_current_tabpage())
592
-
expect('oldtab')
593
-
eq(1, #meths.list_tabpages())
594
671
end)
595
672
-- TODO: this case is too hard to deal with
596
673
pending('if called from floating window with another buffer', function()
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