Skip to content

bug: E19 Mark has invalid line number when ctrl-o #625

Open

Description

@gzbfgjf2

Did you check the docs and existing issues?

  • I have read the docs
  • I have searched the existing issues

Neovim version (nvim -v)

NVIM v0.11.0 Build type: Release

Operating system/version

NixOS 25.05.20250412.2631b0b (Warbler)

Describe the bug

When navigating directories via the - key creates entries in the jump list. After visiting several directories this way, then quitting and relaunching Neovim, attempting to navigate backward using <C-o> can sometimes trigger the following error:

E19: Mark has invalid line number

This error does not occur consistently. It seems the visiting more directories before relaunching will make it more possible to encounter the error.

Observations

  • Inspecting the jump list (:jumps) after restarting Neovim shows that some entries corresponding to oil:// buffers have line numbers that exceed the number of items in the respective directory—even when all hidden items are shown (the wrong line number will increase further if the hidden items are shown).
  • It appears that the line numbers associated with these jump entries are incorrect or become corrupted after restarting Neovim. They are fine before quiting Neovim.

Related issues

What is the severity of this bug?

minor (annoyance)

Steps To Reproduce

  1. mkdir -p a/{b,c,d}
  2. nvim -u repro.lua
  3. "-" to go to current directories
  4. navigate to some directories with "enter", "-" and "jk"
  5. close neovim and re-open neovim
  6. ctrl-o to go to previous directories handled by oil oil:///....
  7. E19 error will appear

Expected Behavior

ctrl-o till the end of the jumplist without any errors

Directory structure

.repro
repro.lua
a
a/b
a/c
a/d

Repro

-- save as repro.lua
-- run with nvim -u repro.lua
-- DO NOT change the paths
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "runtime", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({
    "git",
    "clone",
    "--filter=blob:none",
    "--single-branch",
    "https://github.com/folke/lazy.nvim.git",
    lazypath,
  })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  {
        "stevearc/oil.nvim",
        config = function()
            require("oil").setup({
              -- add any needed settings here
  		cleanup_delay_ms = false,
		keymaps = {
		  ["="] = "actions.cd",
		  ["`"] = false,
		  ["<C-v>"] = "actions.select_vsplit",
		  ["<C-s>"] = false,
		  ["-"] = { "actions.parent", mode = "n" },
		  ["_"] = { "actions.open_cwd", mode = "n" },
  },
            })
        end,
  },
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
vim.keymap.set("n", "-", "<CMD>Oil<CR>", { desc = "Open parent directory" })

Did you check the bug with a clean config?

  • I have confirmed that the bug reproduces with nvim -u repro.lua using the repro.lua file above.

Activity

  1. necronyxon commented on Feb 16, 2026

    @necronyxon

    You can open Oil in a floating window and set it to fill the screen, so that it looks mostly just like a normal Oil buffer and the jumplist doesn't get tainted.
    The only downside is not being able to jump to/from oil via the jumplist, but at least for me that is not a problem.

    I don't know if there's a better way to do it, but here's a snippet of my config with only the relevant options:

    local oil = require("oil")
    
    oil.setup({
      float = {
        padding = 0, -- fill entire screen
        ---@param conf vim.api.keyset.win_config
        override = function(conf)
          conf.border = "solid" -- remove border color
          return conf
        end,
      },
    })
    
    vim.keymap.set("n", "-", function()
      oil.open_float(nil, nil, function()
        local winnr = vim.api.nvim_get_current_win()
        local bufnr = vim.api.nvim_win_get_buf(winnr)
        -- keep two lines for command line and statusline
        vim.api.nvim_win_set_height(winnr, vim.api.nvim_win_get_height(winnr) - 2)
        -- disable jumplist keybinds
        vim.keymap.set("n", "<C-o>", "<Nop>", { buffer = bufnr })
        vim.keymap.set("n", "<C-i>", "<Nop>", { buffer = bufnr })
    
        local autocmd_group = vim.api.nvim_create_augroup("rafa/close_oil_window", { clear = true })
        vim.api.nvim_create_autocmd({ "BufEnter" }, {
          group = autocmd_group,
          desc = "Close oil window before opening a new buffer",
          callback = function(args)
            if not vim.startswith(args.file, "oil://") then
              if vim.api.nvim_win_is_valid(winnr) then
                vim.api.nvim_win_close(winnr, true)
                vim.api.nvim_set_current_buf(args.buf)
                vim.api.nvim_clear_autocmds({ group = autocmd_group })
              end
            end
          end,
        })
      end)
    end, { desc = "[OIL] Open parent directory in floating window" })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions