Skip to content

bug: treesitter selection + config.search.incremental = true causes the initial selection to be the entire buffer #27

@IndianBoy42

Description

@IndianBoy42

Did you check docs and existing issues?

  • I have read all the flash.nvim docs
  • I have searched the existing issues of flash.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0-dev-541+g96b94f8d7

Operating system/version

Pop!_OS 22.04 LTS

Describe the bug

When config.search.incremental is set (globally or within the treesitter mode) and I start flash.treesitter with the window view scrolled so that the first line of the buffer is not visible. The window viewport jumps to the top of the buffer and, sometimes, the whole buffer is preselected. I can still hit one of the other labels (that are may not even be visible anymore) to do the selection. I believe the whole buffer is preselected if scrolling to the top causes all of the other ranges/labels to not be visible anymore

Removing config.search.incremental = true or adding config.modes.treesitter.search.incremental = false makes this stop happening (the viewport is stable)

Steps To Reproduce

  1. With config.search.incremental = true, scroll down so the first line is no longer visible and start treesitter selection yS
  2. The window viewport is scrolled to the top and potentially the initial selection is not the smallest range but the whole buffer.

Expected Behavior

Shouldn't scroll unnecessarily

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "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", "https://github.com/folke/lazy.nvim.git", lazypath })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
	"folke/tokyonight.nvim",
	{
		"folke/flash.nvim",
		opts = {
			search = {
				incremental = true,
			},
			modes = {
				treesitter = { search = { incremental = true } },
			},
		},
		keys = {
			{
				"s",
				mode = { "n", "x", "o" },
				function()
					-- default options: exact mode, multi window, all directions, with a backdrop
					require("flash").jump()
				end,
			},
			{
				"S",
				mode = { "o", "x" },
				function()
					require("flash").treesitter()
				end,
			},
		},
	},
	-- add any other plugins here
}
require("lazy").setup(plugins, {
	root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here































local a = {
	"folke/tokyonight.nvim",
	{
		"folke/flash.nvim",
		opts = {
			modes = {
				treesitter = { labels = "fdsajkluioprewqmvczx" },
			},
		},
		keys = {
			{
				"s",
				mode = { "n", "x", "o" },
				function()
					-- default options: exact mode, multi window, all directions, with a backdrop
					require("flash").jump()
				end,
			},
			{
				"S",
				mode = { "o", "x" },
				function()
					require("flash").treesitter()
				end,
			},
		},
	},
}

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