Skip to content

Error on creating a new line in insert mode before first non-empty line #54

@yndajas

Description

@yndajas

Describe the bug

Creating an empty line in insert mode before the first non-empty line causes an error

Error executing vim.schedule lua callback: .../neovim/0.11.4/share/nvim/runtime/
lua/vim/treesitter.lua:384: Invalid position: row and col must be non-negative
stack traceback:
        [C]: in function 'assert'
        .../neovim/0.11.4/share/nvim/runtime/lua/vim/treesitter.lua:384: in func
tion 'get_node'
        .../nvim-treesitter-endwise/lua/nvim-treesitter/endwise.lua:124: in func
tion 'endwise'
        .../nvim-treesitter-endwise/lua/nvim-treesitter/endwise.lua:216: in func
tion ''
        vim/_editor.lua: in function <vim/_editor.lua:0>

To Reproduce

  1. Open an empty Ruby or Lua file
  2. In insert mode, press enter -> error
  3. Create a non-empty line
  4. In insert mode, navigate to the start of the non-empty line and press enter -> error
  5. In insert mode, navigate to any empty line before the first non-empty line and press enter -> error

Expected behavior

No error on creating a new empty line

Screengrab

Screen.Recording.2025-09-13.at.16.01.56.mov

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions