jake-stewart/multicursor.nvim

Wanted: option to disable wrapping in mc.{prev,next}Cursor

Closed this issue · 3 comments

I was gonna make this suggestion after clearing up #69, but it seems that you might be a step ahead of me with the CursorContext:seekCursor refactor. :)

But basically, I was going to point out that it's not so easy to disable the wrapping from the mc.{prev,next}Cursor mappings, which are now made more complex by handling the enabled/disabled cursors. So it would be convenient to be able to pass something in so that the trues hard-coded in

local cursor = ctx:seekCursor(mainCursor:getPos(), direction, true)
and
local cursor = ctx:seekCursor(mainCursor:getPos(), direction, true, opts)
could be overridden. In the end, I'm imagining being able to do something like

vim.keymap.set("n", "<right>", function() mc.nextCursor({ wrap = false }) end)
vim.keymap.set("n", "<left>", function() mc.prevCursor({ wrap = false }) end)

Existing mappings like vim.keymap.set("n", "<right>", mc.nextCursor) could remain backwards compatible by defaulting the opts to wrap = true.

@ajvondrak I think I'd rather have wrap as a regular param, instead of an options dict.

So you would do mc.nextCursor(false) to disable wrapping. if the wrap parameter is nil, then it can default to true.

sorted

Works for me. Thanks!