mirror of
https://github.com/neovim/neovim.git
synced 2026-04-23 15:55:36 +00:00
fix(quickfix): always split from current window #33807
Problem: `:copen` opens at the bottom by switching to `lastwin`,
needlessly changing the window it inherits context from.
Solution: Use the `WSP_BOT` flag to `win_split()` to open at the bottom.
This commit is contained in:
@@ -3874,14 +3874,10 @@ static int qf_open_new_cwindow(qf_info_T *qi, int height)
|
|||||||
// The current window becomes the previous window afterwards.
|
// The current window becomes the previous window afterwards.
|
||||||
win_T *const win = curwin;
|
win_T *const win = curwin;
|
||||||
|
|
||||||
if (IS_QF_STACK(qi) && cmdmod.cmod_split == 0) {
|
// Default is to open the window below the current window or at the bottom,
|
||||||
// Create the new quickfix window at the very bottom, except when
|
// except when :belowright or :aboveleft is used.
|
||||||
// :belowright or :aboveleft is used.
|
|
||||||
win_goto(lastwin);
|
|
||||||
}
|
|
||||||
// Default is to open the window below the current window
|
|
||||||
if (cmdmod.cmod_split == 0) {
|
if (cmdmod.cmod_split == 0) {
|
||||||
flags = WSP_BELOW;
|
flags = IS_QF_STACK(qi) ? WSP_BOT : WSP_BELOW;
|
||||||
}
|
}
|
||||||
flags |= WSP_NEWLOC;
|
flags |= WSP_NEWLOC;
|
||||||
if (win_split(height, flags) == FAIL) {
|
if (win_split(height, flags) == FAIL) {
|
||||||
|
|||||||
@@ -4,30 +4,22 @@ local Screen = require('test.functional.ui.screen')
|
|||||||
local clear, feed, api = n.clear, n.feed, n.api
|
local clear, feed, api = n.clear, n.feed, n.api
|
||||||
local insert, command = n.insert, n.command
|
local insert, command = n.insert, n.command
|
||||||
|
|
||||||
describe('quickfix selection highlight', function()
|
describe('quickfix', function()
|
||||||
local screen
|
local screen
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
clear()
|
clear()
|
||||||
|
|
||||||
screen = Screen.new(25, 10)
|
screen = Screen.new(25, 10)
|
||||||
screen:set_default_attr_ids({
|
screen:add_extra_attr_ids({
|
||||||
[1] = { foreground = Screen.colors.Blue, bold = true },
|
[100] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.WebGreen },
|
||||||
[2] = { reverse = true },
|
[101] = { foreground = Screen.colors.Brown, background = Screen.colors.WebGreen },
|
||||||
[3] = { foreground = Screen.colors.Brown },
|
[102] = { background = Screen.colors.WebGreen },
|
||||||
[4] = { reverse = true, bold = true },
|
[103] = { background = Screen.colors.Red, foreground = Screen.colors.SlateBlue },
|
||||||
[5] = { background = Screen.colors.WebGreen },
|
[104] = { background = Screen.colors.Red, foreground = Screen.colors.Brown },
|
||||||
[6] = { background = Screen.colors.WebGreen, foreground = Screen.colors.Brown },
|
[105] = { background = Screen.colors.Fuchsia },
|
||||||
[7] = { background = Screen.colors.Red1 },
|
[106] = { foreground = Screen.colors.Red, background = Screen.colors.Fuchsia },
|
||||||
[8] = { background = Screen.colors.Red1, foreground = Screen.colors.Brown },
|
[107] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Fuchsia },
|
||||||
[9] = { background = Screen.colors.Magenta },
|
[108] = { foreground = Screen.colors.Brown, background = Screen.colors.Fuchsia },
|
||||||
[10] = { background = Screen.colors.Magenta, foreground = Screen.colors.Red1 },
|
|
||||||
[11] = { foreground = Screen.colors.Red1 },
|
|
||||||
[12] = { background = Screen.colors.Magenta, foreground = Screen.colors.Brown },
|
|
||||||
[13] = { background = Screen.colors.WebGreen, foreground = Screen.colors.SlateBlue },
|
|
||||||
[14] = { foreground = Screen.colors.SlateBlue },
|
|
||||||
[15] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Red1 },
|
|
||||||
[16] = { foreground = Screen.colors.SlateBlue, background = Screen.colors.Fuchsia },
|
|
||||||
})
|
})
|
||||||
|
|
||||||
api.nvim_set_option_value('errorformat', '%m %l', {})
|
api.nvim_set_option_value('errorformat', '%m %l', {})
|
||||||
@@ -57,19 +49,19 @@ describe('quickfix selection highlight', function()
|
|||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('using default Search highlight group', function()
|
it('Search selection highlight', function()
|
||||||
command('copen')
|
command('copen')
|
||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
Line 1 |
|
Line 1 |
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{13:^|}{6:1}{13:|}{5: Line }|
|
{100:^|}{101:1}{100:|}{102: Line }|
|
||||||
{14:|}{3:2}{14:|} Line |
|
{16:|}{8:2}{16:|} Line |
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -78,18 +70,18 @@ describe('quickfix selection highlight', function()
|
|||||||
screen:expect([[
|
screen:expect([[
|
||||||
Line 1 |
|
Line 1 |
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{14:|}{3:1}{14:|} Line |
|
{16:|}{8:1}{16:|} Line |
|
||||||
{13:^|}{6:2}{13:|}{5: Line }|
|
{100:^|}{101:2}{100:|}{102: Line }|
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('using QuickFixLine highlight group', function()
|
it('QuickFixLine selection highlight', function()
|
||||||
command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
|
command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
|
||||||
|
|
||||||
command('copen')
|
command('copen')
|
||||||
@@ -97,13 +89,13 @@ describe('quickfix selection highlight', function()
|
|||||||
screen:expect([[
|
screen:expect([[
|
||||||
Line 1 |
|
Line 1 |
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{15:^|}{8:1}{15:|}{7: Line }|
|
{103:^|}{104:1}{103:|}{30: Line }|
|
||||||
{14:|}{3:2}{14:|} Line |
|
{16:|}{8:2}{16:|} Line |
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
@@ -112,18 +104,18 @@ describe('quickfix selection highlight', function()
|
|||||||
screen:expect([[
|
screen:expect([[
|
||||||
Line 1 |
|
Line 1 |
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{14:|}{3:1}{14:|} Line |
|
{16:|}{8:1}{16:|} Line |
|
||||||
{15:^|}{8:2}{15:|}{7: Line }|
|
{103:^|}{104:2}{103:|}{30: Line }|
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('combines with CursorLine', function()
|
it('selection highlight combines with CursorLine', function()
|
||||||
command('set cursorline')
|
command('set cursorline')
|
||||||
command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE')
|
command('highlight QuickFixLine guifg=Red guibg=NONE gui=NONE')
|
||||||
command('highlight CursorLine guibg=Fuchsia')
|
command('highlight CursorLine guibg=Fuchsia')
|
||||||
@@ -131,35 +123,35 @@ describe('quickfix selection highlight', function()
|
|||||||
command('copen')
|
command('copen')
|
||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{9:Line 1 }|
|
{105:Line 1 }|
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{10:^|1| Line }|
|
{106:^|1| Line }|
|
||||||
{14:|}{3:2}{14:|} Line |
|
{16:|}{8:2}{16:|} Line |
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('j')
|
feed('j')
|
||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{9:Line 1 }|
|
{105:Line 1 }|
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{11:|1| Line }|
|
{19:|1| Line }|
|
||||||
{16:^|}{12:2}{16:|}{9: Line }|
|
{107:^|}{108:2}{107:|}{105: Line }|
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('QuickFixLine background takes precedence over CursorLine', function()
|
it('QuickFixLine selection highlight background takes precedence over CursorLine', function()
|
||||||
command('set cursorline')
|
command('set cursorline')
|
||||||
command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
|
command('highlight QuickFixLine guibg=Red guifg=NONE gui=NONE')
|
||||||
command('highlight CursorLine guibg=Fuchsia')
|
command('highlight CursorLine guibg=Fuchsia')
|
||||||
@@ -167,30 +159,48 @@ describe('quickfix selection highlight', function()
|
|||||||
command('copen')
|
command('copen')
|
||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{9:Line 1 }|
|
{105:Line 1 }|
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{15:^|}{8:1}{15:|}{7: Line }|
|
{103:^|}{104:1}{103:|}{30: Line }|
|
||||||
{14:|}{3:2}{14:|} Line |
|
{16:|}{8:2}{16:|} Line |
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
|
|
||||||
feed('j')
|
feed('j')
|
||||||
|
|
||||||
screen:expect([[
|
screen:expect([[
|
||||||
{9:Line 1 }|
|
{105:Line 1 }|
|
||||||
{2:[No Name] [+] }|
|
{2:[No Name] [+] }|
|
||||||
{15:|}{8:1}{15:|}{7: Line }|
|
{103:|}{104:1}{103:|}{30: Line }|
|
||||||
{16:^|}{12:2}{16:|}{9: Line }|
|
{107:^|}{108:2}{107:|}{105: Line }|
|
||||||
{14:|}{3:3}{14:|} Line |
|
{16:|}{8:3}{16:|} Line |
|
||||||
{14:|}{3:4}{14:|} Line |
|
{16:|}{8:4}{16:|} Line |
|
||||||
{14:|}{3:5}{14:|} Line |
|
{16:|}{8:5}{16:|} Line |
|
||||||
{14:||} |
|
{16:||} |
|
||||||
{4:[Quickfix List] [-] }|
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
||||||
|
]])
|
||||||
|
end)
|
||||||
|
|
||||||
|
it('does not inherit from non-current floating window', function()
|
||||||
|
api.nvim_open_win(0, true, { width = 6, height = 2, relative = 'win', bufpos = { 3, 0 } })
|
||||||
|
api.nvim_set_option_value('rightleft', true, { win = 0 })
|
||||||
|
command('wincmd w | copen')
|
||||||
|
screen:expect([[
|
||||||
|
Line 1 |
|
||||||
|
{2:[No Name] [+] }|
|
||||||
|
{100:^|}{101:1}{100:|}{102: Line }|
|
||||||
|
{16:|}{8:2}{16:|} Line {4:1 eniL}|
|
||||||
|
{16:|}{8:3}{16:|} Line {4:2 eniL}|
|
||||||
|
{16:|}{8:4}{16:|} Line |
|
||||||
|
{16:|}{8:5}{16:|} Line |
|
||||||
|
{16:||} |
|
||||||
|
{3:[Quickfix List] [-] }|
|
||||||
|
|
|
|
||||||
]])
|
]])
|
||||||
end)
|
end)
|
||||||
|
|||||||
Reference in New Issue
Block a user