feat(explorer): keep expanded dir state. Closes #816

This commit is contained in:
Folke Lemaitre 2025-01-31 13:55:51 +01:00
parent cd61c235a5
commit 31984e88a5
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040

View file

@ -6,6 +6,7 @@ local M = {}
---@type table<snacks.Picker, snacks.picker.explorer.State>
M._state = setmetatable({}, { __mode = "k" })
local uv = vim.uv or vim.loop
local expanded = {} ---@type table<string, boolean>
---@class snacks.picker.explorer.Item: snacks.picker.finder.Item
---@field file string
@ -32,7 +33,8 @@ function State.new(picker)
self.picker = picker:ref()
local filter = picker:filter()
self.cwd = filter.cwd
self.expanded = { [self.cwd] = true }
self.expanded = expanded
self.expanded[self.cwd] = true
local buf = vim.api.nvim_win_get_buf(picker.main)
local buf_file = vim.fs.normalize(vim.api.nvim_buf_get_name(buf))
if uv.fs_stat(buf_file) then