mrjones2014 / smart-splits.nvim

🧠 Smart, seamless, directional navigation and resizing of Neovim + terminal multiplexer splits. Supports tmux, Wezterm, and Kitty. Think about splits in terms of "up/down/left/right".
MIT License
976 stars 43 forks source link

[BUG]: Error when moving to a split with a shorter buffer #70

Closed TxHawks closed 1 year ago

TxHawks commented 1 year ago

Describe the bug Say we have two splits, one with BufferA, which has 200 lines, and another with BufferB, which has 30 lines. If my cursor is on a line greater than 30, say 35 in BufferA, and I switch to the split that has BufferB using require("smart-splits").swap_buf_*(), it will switch to the second split, and try and move the cursor to line 35 of BufferB and then try to adjust line by line, which doesn't exist, which results in the following errors:

E315: ml_get: invalid lnum: 35
E315: ml_get: invalid lnum: 34
E315: ml_get: invalid lnum: 33
E315: ml_get: invalid lnum: 32
E315: ml_get: invalid lnum: 31

Expected behavior To directly jump to the last line of the file, but I'd actually be happy if there was a configuration option to not adjust the line in the split I'm moving to so that the cursor stays where it last was

Version Info (please complete the following information):

Minimal init.lua The config options I use to setup smart-splits are:

      cursor_follows_swapped_bufs = true,
      ignored_filetypes = {
        "Outline",
        "Trouble",
        "help",
        "lazy",
        "neo-tree",
        "nofile",
        "propmpt",
        "quickfix",
        "toggleterm",
      },
      multiplexer_integration = "tmux",
      disable_multiplexer_nav_when_zoomed = true,
mrjones2014 commented 1 year ago

I tried on 0.8.3, 0.8.0, and nightly, and could not reproduce the issue.

Can you try to reproduce with no other plugins installed and provide a minimal init.lua that can be used like nvim -nu ./init.lua? Use this template: https://github.com/mrjones2014/smart-splits.nvim/discussions/72

mrjones2014 commented 1 year ago

Closing as no minimal init.lua has been provided. Reopen with a minimal init.lua if the issue persists.