Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(builtin.current_buffer_fuzzy_find): jump to first matched char #2909

Merged
merged 5 commits into from
Feb 15, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lua/telescope/builtin/__files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,20 @@ files.current_buffer_fuzzy_find = function(opts)
return
end

vim.api.nvim_win_set_cursor(0, { selection.lnum, 0 })
local searched_for = require("telescope.actions.state").get_current_line()
local first_search_char = string.sub(searched_for, 1, 1)

local column_as_is = string.find(selection.text, first_search_char)
local reversed_char
if first_search_char == string.upper(first_search_char) then
reversed_char = string.lower(first_search_char)
else
reversed_char = string.upper(first_search_char)
end
local column_reversed = string.find(selection.text, reversed_char)
local column = math.min(column_as_is or math.huge, column_reversed or math.huge)
jamestrew marked this conversation as resolved.
Show resolved Hide resolved

vim.api.nvim_win_set_cursor(0, { selection.lnum, column })
end,
}

Expand Down
Loading