[bug?] [mini.ai] next and prev search methods behave asymmetrically
#2294
-
Contributing guidelines
Module(s)mini.ai Questionai.mp4local MiniAi = require("mini.ai")
MiniAi.setup({
custom_textobjects = {
F = MiniAi.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }),
},
})
vim.keymap.set("n", "gj", function()
MiniAi.move_cursor("left", "a", "F", { search_method = "next" })
end, {})
vim.keymap.set("n", "gk", function()
MiniAi.move_cursor("left", "a", "F", { search_method = "prev" })
end, {})
local function outer1()
local function inner1() end
local function inner2() end
inner1()
inner2()
end
function outer2()
local function inner1() end
local function inner2() end
inner1()
inner2()
end
local function outer3() end
outer1()
outer2()
outer3()Press: I'd like to hear other opinions, but to me it feels unintuitive. Personally, I'd prefer the |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
It seems to work as expected and is mostly the matter of choosing the correct distance approach when computing which span is the closest. It was a long time ago, but I remember trying to find the most intuitive behavior and the current one was the one. The basic idea is to find the region for a textobject match that is "closest in that direction". This means that:
I don't think there is a universally good answer to this, apart from maybe a more comprehensive set of mappings. Like all combinations of |
Beta Was this translation helpful? Give feedback.
It seems to work as expected and is mostly the matter of choosing the correct distance approach when computing which span is the closest.
It was a long time ago, but I remember trying to find the most intuitive behavior and the current one was the one. The basic idea is to find the region for a textobject match that is "closest in that direction". This means that:
gjcases, even the ones nested in other regions.gkcases, since every one moves cursor to the …