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

fix goto_last_window #373

Merged
merged 6 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
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
24 changes: 12 additions & 12 deletions lua/lean/infoview.lua
Original file line number Diff line number Diff line change
Expand Up @@ -589,24 +589,24 @@ end

---@return Info
function Info:new(opts)
local pins_element = Element:new {
name = 'info',
events = {
goto_last_window = function()
if not self.last_window then
return
end
vim.api.nvim_set_current_win(self.last_window)
end,
},
}
local new_info = setmetatable({
pins = {},
__infoview = opts.infoview,
__pins_element = pins_element,
__pins_element = Element:new { name = 'info' },
__diff_pin_element = Element:new { name = 'diff' },
__win_event_disable = false, -- FIXME: This too is really confusing
}, self)

new_info.__pins_element.events = {
goto_last_window = function()
print(vim.inspect(new_info))
funemy marked this conversation as resolved.
Show resolved Hide resolved
if not new_info.last_window then
return
end
vim.api.nvim_set_current_win(new_info.last_window)
end,
}

new_info.pin = Pin:new {
id = '1',
paused = options.autopause,
Expand Down
2 changes: 1 addition & 1 deletion lua/lean/tui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local util = require 'lean._util'
---keys trigger it (or theoretically mouse events, though we don't do so in
---practice at the moment).
---
---In gneeral, resist the temptation to add new event types here, as this
---In general, resist the temptation to add new event types here, as this
---entire concept feels slightly like "misdirection" that could be redesigned
---at least because it mixes abstraction layers between general events and ones
---that are very specific to a particular context (like "going to the last
Expand Down
33 changes: 33 additions & 0 deletions spec/infoview/jump_spec.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---@brief [[
--- Tests for jumping from Lean file to infoview and back
---@brief ]]

local fixtures = require 'spec.fixtures'
local helpers = require 'spec.helpers'
local infoview = require 'lean.infoview'

require('lean').setup {}

describe('infoview jumping', function()
local lean_window

it('jumps from Lean file to infoview', function()
assert.is.equal(1, #vim.api.nvim_tabpage_list_wins(0))
lean_window = vim.api.nvim_get_current_win()

vim.cmd('edit! ' .. fixtures.project.some_existing_file)
local current_infoview = infoview.get_current_infoview()

current_infoview:open()
-- Both Lean and infoview windows exist
assert.windows.are(lean_window, current_infoview.window)

vim.cmd 'LeanGotoInfoview'
funemy marked this conversation as resolved.
Show resolved Hide resolved
assert.current_window.is(current_infoview.window)
end)

it('jumps back from infoview to the associated Lean file', function()
helpers.feed '<LocalLeader><Tab>'
assert.current_window.is(lean_window)
end)
end)
Loading