Skip to content

Commit

Permalink
refactor(outline): change jump behavior window (#1310)
Browse files Browse the repository at this point in the history
  • Loading branch information
anasrar authored Oct 6, 2023
1 parent aebd978 commit d82fd41
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lua/lspsaga/symbol/outline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ function ot:toggle_or_jump()
local range = node.value.selectionRange or node.value.location.range
local pos = { range.start.line + 1, range.start.character }

local main_buf = self.main_buf
local callerwinid = self.callerwinid
if config.outline.layout == 'normal' and config.outline.close_after_jump then
util.close_win({ self.winid, self.preview_winid })
clean_ctx()
Expand All @@ -315,9 +315,8 @@ function ot:toggle_or_jump()
clean_ctx()
end

local wins = fn.win_findbuf(main_buf)
api.nvim_set_current_win(wins[#wins])
api.nvim_win_set_cursor(wins[#wins], pos)
api.nvim_set_current_win(callerwinid)
api.nvim_win_set_cursor(callerwinid, pos)
local width = #api.nvim_get_current_line()
beacon({ pos[1] - 1, 0 }, width)
end
Expand Down Expand Up @@ -518,7 +517,7 @@ function ot:keymap()
end
local pos =
{ node.value.selectionRange.start.line + 1, node.value.selectionRange.start.character }
local main_buf = self.main_buf
local callerwinid = self.callerwinid

if config.outline.layout == 'normal' and config.outline.close_after_jump then
util.close_win({ self.winid, self.rwinid })
Expand All @@ -528,9 +527,8 @@ function ot:keymap()
clean_ctx()
end

local wins = fn.win_findbuf(main_buf)
api.nvim_set_current_win(wins[#wins])
api.nvim_win_set_cursor(wins[#wins], pos)
api.nvim_set_current_win(callerwinid)
api.nvim_win_set_cursor(callerwinid, pos)
local width = #api.nvim_get_current_line()
beacon({ pos[1] - 1, 0 }, width)
end)
Expand All @@ -549,6 +547,7 @@ function ot:outline(buf)
end

self.main_buf = buf or api.nvim_get_current_buf()
self.callerwinid = api.nvim_get_current_win()
local curline = api.nvim_win_get_cursor(0)[1]
local res = not util.nvim_ten() and symbol:get_buf_symbols(buf)
or require('lspsaga.symbol.head'):get_buf_symbols(buf)
Expand Down

0 comments on commit d82fd41

Please sign in to comment.