Skip to content

Commit 0426b9b

Browse files
committed
Simplified fix - minimal changes (Sun Nov 2 10:24:18 PST 2025)
1 parent e1296c3 commit 0426b9b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

lua/treewalker/movement.lua

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,18 @@ end
2626

2727
---@return nil
2828
function M.move_out()
29+
-- Move cursor to first non-whitespace character of current line (like normal! ^)
30+
local current_row = vim.fn.line('.')
31+
local current_col = vim.fn.col('.')
32+
local current_line = require('treewalker.lines').get_line(current_row)
33+
if current_line then
34+
local start_col = require('treewalker.lines').get_start_col(current_line)
35+
-- Only move if we're not already at the first non-whitespace character
36+
if current_col ~= start_col then
37+
vim.api.nvim_win_set_cursor(0, { current_row, start_col - 1 }) -- Convert to 0-indexed
38+
end
39+
end
40+
2941
local node = nodes.get_current()
3042
local target, row = targets.out(node)
3143
if not (target and row) then

0 commit comments

Comments
 (0)