diff --git a/src/nvim/window.c b/src/nvim/window.c index 9c27ff2857..0c0c00335a 100644 --- a/src/nvim/window.c +++ b/src/nvim/window.c @@ -4374,6 +4374,10 @@ tabpage_T *find_tabpage(int n) tabpage_T *tp; int i = 1; + if (n == 0) { + return curtab; + } + for (tp = first_tabpage; tp != NULL && i != n; tp = tp->tp_next) { i++; } diff --git a/test/functional/editor/tabpage_spec.lua b/test/functional/editor/tabpage_spec.lua index b6fbebb20c..e829821a64 100644 --- a/test/functional/editor/tabpage_spec.lua +++ b/test/functional/editor/tabpage_spec.lua @@ -137,6 +137,11 @@ describe('tabpage', function() eq(1, fn.nvim_tabpage_get_number(0)) end) + it('0 means current tabpage for gettabvar()', function() + command('let t:tabvar = 42') + eq(42, fn.gettabvar(0, 'tabvar')) + end) + it(':tabs does not overflow IObuff with long path with comma #20850', function() api.nvim_buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024)) command('tabs')