mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge #4874 'Restore vim-like tab dragging'
This commit is contained in:
commit
2daf54ee8d
@ -2110,6 +2110,20 @@ static void op_function(oparg_T *oap)
|
||||
}
|
||||
}
|
||||
|
||||
// Move the current tab to tab in same column as mouse or to end of the
|
||||
// tabline if there is no tab there.
|
||||
static void move_tab_to_mouse(void)
|
||||
{
|
||||
int tabnr = tab_page_click_defs[mouse_col].tabnr;
|
||||
if (tabnr <= 0) {
|
||||
tabpage_move(9999);
|
||||
} else if (tabnr < tabpage_index(curtab)) {
|
||||
tabpage_move(tabnr - 1);
|
||||
} else {
|
||||
tabpage_move(tabnr);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Do the appropriate action for the current mouse click in the current mode.
|
||||
* Not used for Command-line mode.
|
||||
@ -2346,12 +2360,7 @@ do_mouse (
|
||||
if (mouse_row == 0 && firstwin->w_winrow > 0) {
|
||||
if (is_drag) {
|
||||
if (in_tab_line) {
|
||||
if (tab_page_click_defs[mouse_col].type == kStlClickTabClose) {
|
||||
tabpage_move(9999);
|
||||
} else {
|
||||
int tabnr = tab_page_click_defs[mouse_col].tabnr;
|
||||
tabpage_move(tabnr < tabpage_index(curtab) ? tabnr - 1 : tabnr);
|
||||
}
|
||||
move_tab_to_mouse();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@ -2466,10 +2475,7 @@ do_mouse (
|
||||
}
|
||||
return true;
|
||||
} else if (is_drag && in_tab_line) {
|
||||
tabpage_move(tab_page_click_defs[mouse_col].type == kStlClickTabClose
|
||||
? 9999
|
||||
: tab_page_click_defs[mouse_col].tabnr - 1);
|
||||
in_tab_line = false;
|
||||
move_tab_to_mouse();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -141,8 +141,8 @@ describe('server -> client', function()
|
||||
|
||||
describe('when the client is a recursive vim instance', function()
|
||||
if os.getenv("TRAVIS") and helpers.os_name() == "osx" then
|
||||
-- XXX: Hangs Travis OSX since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
||||
pending("[Hangs on Travis OSX. #5002]", function() end)
|
||||
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
||||
pending("[Hangs on Travis macOS. #5002]", function() end)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -109,8 +109,8 @@ describe('jobs', function()
|
||||
it("will not buffer data if it doesn't end in newlines", function()
|
||||
if os.getenv("TRAVIS") and os.getenv("CC") == "gcc-4.9"
|
||||
and helpers.os_name() == "osx" then
|
||||
-- XXX: Hangs Travis OSX since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
||||
pending("[Hangs on Travis OSX. #5002]", function() end)
|
||||
-- XXX: Hangs Travis macOS since e9061117a5b8f195c3f26a5cb94e18ddd7752d86.
|
||||
pending("[Hangs on Travis macOS. #5002]", function() end)
|
||||
return
|
||||
end
|
||||
|
||||
|
@ -111,6 +111,232 @@ describe('Mouse input', function()
|
||||
]])
|
||||
end)
|
||||
|
||||
describe('tab drag', function()
|
||||
before_each(function()
|
||||
screen:set_default_attr_ids( {
|
||||
[0] = {bold=true, foreground=Screen.colors.Blue},
|
||||
tab = { background=Screen.colors.LightGrey, underline=true },
|
||||
sel = { bold=true },
|
||||
fill = { reverse=true }
|
||||
})
|
||||
screen.timeout = 15000
|
||||
end)
|
||||
|
||||
it('in tabline on filler space moves tab to the end', function()
|
||||
execute('%delete')
|
||||
insert('this is foo')
|
||||
execute('silent file foo | tabnew | file bar')
|
||||
insert('this is bar')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftMouse><4,0>')
|
||||
screen:expect([[
|
||||
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><14,0>')
|
||||
screen:expect([[
|
||||
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('in tabline to the left moves tab left', function()
|
||||
if os.getenv("TRAVIS") and helpers.os_name() == "osx" then
|
||||
pending("[Fails on Travis macOS. #4874]", function() end)
|
||||
return
|
||||
end
|
||||
|
||||
execute('%delete')
|
||||
insert('this is foo')
|
||||
execute('silent file foo | tabnew | file bar')
|
||||
insert('this is bar')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftMouse><11,0>')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><6,0>')
|
||||
screen:expect([[
|
||||
{sel: + bar }{tab: + foo }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('in tabline to the right moves tab right', function()
|
||||
execute('%delete')
|
||||
insert('this is foo')
|
||||
execute('silent file foo | tabnew | file bar')
|
||||
insert('this is bar')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftMouse><4,0>')
|
||||
screen:expect([[
|
||||
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><7,0>')
|
||||
screen:expect([[
|
||||
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('out of tabline under filler space moves tab to the end', function()
|
||||
execute('%delete')
|
||||
insert('this is foo')
|
||||
execute('silent file foo | tabnew | file bar')
|
||||
insert('this is bar')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftMouse><4,0>')
|
||||
screen:expect([[
|
||||
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><4,1>')
|
||||
screen:expect([[
|
||||
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><14,1>')
|
||||
screen:expect([[
|
||||
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('out of tabline to the left moves tab left', function()
|
||||
if os.getenv("TRAVIS") and helpers.os_name() == "osx" then
|
||||
pending("[Fails on Travis macOS. #4874]", function() end)
|
||||
return
|
||||
end
|
||||
|
||||
execute('%delete')
|
||||
insert('this is foo')
|
||||
execute('silent file foo | tabnew | file bar')
|
||||
insert('this is bar')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftMouse><11,0>')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><11,1>')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><6,1>')
|
||||
screen:expect([[
|
||||
{sel: + bar }{tab: + foo }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
|
||||
it('out of tabline to the right moves tab right', function()
|
||||
execute('%delete')
|
||||
insert('this is foo')
|
||||
execute('silent file foo | tabnew | file bar')
|
||||
insert('this is bar')
|
||||
screen:expect([[
|
||||
{tab: + foo }{sel: + bar }{fill: }{tab:X}|
|
||||
this is ba^r |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftMouse><4,0>')
|
||||
screen:expect([[
|
||||
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><4,1>')
|
||||
screen:expect([[
|
||||
{sel: + foo }{tab: + bar }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
feed('<LeftDrag><7,1>')
|
||||
screen:expect([[
|
||||
{tab: + bar }{sel: + foo }{fill: }{tab:X}|
|
||||
this is fo^o |
|
||||
{0:~ }|
|
||||
{0:~ }|
|
||||
|
|
||||
]])
|
||||
end)
|
||||
end)
|
||||
|
||||
describe('tabline', function()
|
||||
before_each(function()
|
||||
screen:set_default_attr_ids( {
|
||||
|
Loading…
Reference in New Issue
Block a user