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

range from source doesn't seem to use correct column #1494

Open
GopherJ opened this issue Oct 9, 2024 · 0 comments
Open

range from source doesn't seem to use correct column #1494

GopherJ opened this issue Oct 9, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@GopherJ
Copy link

GopherJ commented Oct 9, 2024

Describe the bug

if I use viw to select function name, range_from_source still return the whole line

Steps to reproduce

	local start = vim.fn.getpos("v")
	local end_ = vim.fn.getpos(".")
	local start_row = start[2]
	local start_col = start[3]
	local end_row = end_[2]
	local end_col = end_[3]

	-- A user can start visual selection at the end and move backwards
	-- Normalize the range to start < end
	if start_row == end_row and end_col < start_col then
		end_col, start_col = start_col, end_col
	elseif end_row < start_row then
		start_row, end_row = end_row, start_row
		start_col, end_col = end_col, start_col
	end
	if vim.api.nvim_get_mode().mode == "V" then
		start_col = 1
		local lines = vim.api.nvim_buf_get_lines(0, end_row - 1, end_row, true)
		end_col = #lines[1]
	end
	return {
		["start"] = { start_row, start_col - 1 },
		["end"] = { end_row, end_col - 1 },
	}

Expected behavior

return exact column

Neovim version (nvim -v)

NVIM v0.10.1 Build type: Debug LuaJIT 2.1.1713484068 Run "nvim -V1 -v" for more info

lspsaga commit

latest

Terminal name/version

tmux

@GopherJ GopherJ added the bug Something isn't working label Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant