nvim-treesitter / nvim-treesitter-context

Show code context
MIT License
2.43k stars 194 forks source link

No context causes negative height #445

Closed YodaEmbedding closed 2 months ago

YodaEmbedding commented 4 months ago

Description

No root-level header causes incorrect API calls.

Neovim version

0.9.5

Expected behavior

No error. If there is no available context, do not try to display anything.

Actual behavior

Error detected while processing WinScrolled Autocommands for "*":
Error executing lua callback: ...vim-treesitter-context/lua/treesitter-context/render.lua:51: 'height' key must be a positive Integer
stack traceback:
        [C]: in function 'nvim_open_win'
        ...vim-treesitter-context/lua/treesitter-context/render.lua:51: in function 'display_window'
        ...vim-treesitter-context/lua/treesitter-context/render.lua:337: in function 'open'
        .../lazy/nvim-treesitter-context/lua/treesitter-context.lua:50: in function 'open'
        .../lazy/nvim-treesitter-context/lua/treesitter-context.lua:111: in function 'f'
        .../lazy/nvim-treesitter-context/lua/treesitter-context.lua:27: in function <.../lazy/nvim-treesitter-context/lua/treesitter-context.lua:21>

Minimal config

local plugins = {
  ts         = 'https://github.com/nvim-treesitter/nvim-treesitter',
  ts_context = 'https://github.com/nvim-treesitter/nvim-treesitter-context',
  -- ADD ADDITIONAL PLUGINS THAT ARE _NECESSARY_ TO REPRODUCE THE ISSUE
}

for name, url in pairs(plugins) do
  local install_path = '/tmp/nvim/site/'..name
  if vim.fn.isdirectory(install_path) == 0 then
    vim.fn.system { 'git', 'clone', '--depth=1', url, install_path }
  end
  vim.o.runtimepath = install_path..','..vim.o.runtimepath
end

-- ADD INIT.LUA SETTINGS THAT IS _NECESSARY_ FOR REPRODUCING THE ISSUE

Steps to reproduce

  1. nvim --clean -u minimal.lua
  2. Create a markdown document with no headers and 200 lines of text and/or empty lines:
    
    Two
    minutes
    to
    midnight

Rime of the ancient mariner

Hallowed be thy name

...


3. Invoke window scrolling (not cursor scrolling) by `zt` or something.
lewis6991 commented 2 months ago

Can not reproduce, may be fixed.