forked from neovim/neovim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(float): make
screen*()
functions respect floating windows
Resolves neovim#19013.
- Loading branch information
1 parent
7b2b44b
commit 2ba7b6c
Showing
3 changed files
with
122 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
local helpers = require('test.functional.helpers')(after_each) | ||
local clear, eq, meths = helpers.clear, helpers.eq, helpers.meths | ||
local command, funcs = helpers.command, helpers.funcs | ||
|
||
local global_helpers = require('test.helpers') | ||
local neq = global_helpers.neq | ||
|
||
-- Set up two overlapping floating windows | ||
local setup_floating_windows = function() | ||
local base_opts = { | ||
relative = 'editor', | ||
height = 1, | ||
width = 2, | ||
anchor = 'NW', | ||
style = 'minimal', | ||
border = 'none', | ||
} | ||
|
||
local bufnr_1 = meths.create_buf(false, true) | ||
meths.buf_set_lines(bufnr_1, 0, -1, true, { 'aa' }) | ||
local opts_1 = global_helpers.tbl_deep_extend('force', { row = 0, col = 0, zindex = 11 }, base_opts) | ||
meths.open_win(bufnr_1, false, opts_1) | ||
|
||
local bufnr_2 = meths.create_buf(false, true) | ||
meths.buf_set_lines(bufnr_2, 0, -1, true, { 'bb' }) | ||
local opts_2 = global_helpers.tbl_deep_extend('force', { row = 0, col = 1, zindex = 10 }, base_opts) | ||
meths.open_win(bufnr_2, false, opts_2) | ||
|
||
command('redraw') | ||
end | ||
|
||
before_each(function() | ||
clear() | ||
-- These commands result into visible text `aabc`. | ||
-- `aab` - from floating windows, `c` - from text in regular window. | ||
meths.buf_set_lines(0, 0, -1, true, { 'cccc' }) | ||
setup_floating_windows() | ||
end) | ||
|
||
describe('screenattr()', function() | ||
it('respects floating windows', function() | ||
local attr_1 = funcs.screenattr(1, 1) | ||
local attr_2 = funcs.screenattr(1, 2) | ||
local attr_3 = funcs.screenattr(1, 3) | ||
local attr_4 = funcs.screenattr(1, 4) | ||
eq(attr_1, attr_2) | ||
eq(attr_1, attr_3) | ||
neq(attr_1, attr_4) | ||
end) | ||
end) | ||
|
||
describe('screenchar()', function() | ||
it('respects floating windows', function() | ||
eq(97, funcs.screenchar(1, 1)) | ||
eq(97, funcs.screenchar(1, 2)) | ||
eq(98, funcs.screenchar(1, 3)) | ||
eq(99, funcs.screenchar(1, 4)) | ||
end) | ||
end) | ||
|
||
describe('screenchars()', function() | ||
it('respects floating windows', function() | ||
eq({ 97 }, funcs.screenchars(1, 1)) | ||
eq({ 97 }, funcs.screenchars(1, 2)) | ||
eq({ 98 }, funcs.screenchars(1, 3)) | ||
eq({ 99 }, funcs.screenchars(1, 4)) | ||
end) | ||
end) | ||
|
||
describe('screenstring()', function() | ||
it('respects floating windows', function() | ||
eq('a', funcs.screenstring(1, 1)) | ||
eq('a', funcs.screenstring(1, 2)) | ||
eq('b', funcs.screenstring(1, 3)) | ||
eq('c', funcs.screenstring(1, 4)) | ||
end) | ||
end) |