move.nvim icon indicating copy to clipboard operation
move.nvim copied to clipboard

weird MoveBlock selection when moved through a foldable region

Open RaafatTurki opened this issue 3 years ago • 2 comments

I've recorded it here, It only happens when moving the block downwards.

This was tested with more than one fold setting so I wouldn't say the issue lies there

I should point that I've faced the same issue with my hacky block-moving keybind, in fact my hope was using a more maintained solution like this plugin would fix it.

here's the same text block for testing purposes

--- defines div and mul
-- @module side

--- multiplies two numbers.
function mul(p1, p2)
  return p1 * p2
end

--- divides two numbers.
function div(p1, p2)
  return p1 / p2
end

-- entities: This <foo>, quot: ", ampersand: &
-- escaped markdown: __foo\_bar__
-- **bold** *italic*
local foo = 123

-- escaped markdown: `foo\_bar`
local bar = 123

local a = {}

local ASD = 123
local ASD = 123

RaafatTurki avatar Apr 25 '22 11:04 RaafatTurki

It seems that when entering in a foldable section, the references of which lines to move is mixed up with the ones on the fold. Will check it out, thanks!

fedepujol avatar Apr 25 '22 12:04 fedepujol

Best case scenario is:

  • this gets fixed
  • moved text jumps over folds (instead of opening them up and going inside them)

I don't think I know any editor that has this feature

RaafatTurki avatar May 01 '22 01:05 RaafatTurki

I can't reproduce this as the video is showing. I've only came close, if the foldings were closed.

Can you share your folding config? Perhaps mine it's different.

fedepujol avatar Sep 08 '22 18:09 fedepujol

Hey, I should mention that I no longer use this plugin so idk if this issue still applies. my folding config:

vim.o.foldmethod        = 'expr'                        -- Tree sitter folding
vim.o.foldexpr          = 'nvim_treesitter#foldexpr()'  -- Tree sitter folding
vim.o.foldtext          = "substitute(getline(v:foldstart),'\t',repeat(' ',&tabstop),'g').' ... '.trim(getline(v:foldend))"   -- Sexy minimal folds
vim.o.foldnestmax       = 10                            -- Maximum amount of nested folds
vim.o.foldminlines      = 1                             -- Minimum amount of lines per fold

it should look like this

RaafatTurki avatar Sep 08 '22 19:09 RaafatTurki

Thanks! The bug happens when foldexpr is set to nvim_treesitter#foldexpr().

The trick was to update the folds after the block was moved.

fedepujol avatar Sep 09 '22 21:09 fedepujol