feat: resume last picker (#405)#438
Conversation
73c3655 to
9d6b287
Compare
|
cool thank you let me know when its ready |
|
Hi @dmtrKovalenko , the PR is ready for review. I'm happy to update/rewrite if we have better approach! |
|
Thanks for the review @dmtrKovalenko , i've addressed the comments. |
|
oh well looking into these changes I think this is again wrong I made a wrong suggestion origianlly I am sorry what we actually want to persist is query, right? I mean we never know how results would change in between there is no reason to store the items if the files were deleted, or the order of file items would change as well? I can try to update the PR myself I am sorry for kicking you back and forth |
|
No problem @dmtrKovalenko, i can update the PR. Do you mean this suggestion #438 (comment)? |
|
@dmtrKovalenko I have spent a bit of time reviewing which fields on the state to be stored and can't make a conclusion, since there's a lot, and testing each when toggle the field takes time. So need your suggestion on choosing which field on Regarding the current implementation, I've tested with cases where the results changed between 2 searches, and it works fine. |
|
Also, just push a new commit to handle empty query case, we shouldn't save the state when query is empty |
4be3f1c to
d3c0284
Compare
|
Hi @dmtrKovalenko , please help take a look at this PR again when u have time. Thank you! |
|
@gustav-fff please rebase this PR and fix any CI issues (in a separate commit if they are not flaky) tag me here when you done |
|
[triage-bot] DIRECTED: cannot rebase cleanly — needs re-implementation, not a rebase. PR head is
CI status: only red check is Also: your 2026-05-12 review point (persist only Suggested next step: reduce scope to "save query (+ mode) only" and re-target against the post-#564 module layout. Happy to take a swing at that as a fresh branch if you want — tag me with the go-ahead. Honk-Honk 🪿 |
Add ability to resume the last closed picker with full state (query, results, cursor, mode) by adapting for the refactored module structure. In the coordinator (picker_ui.lua): - save_state_and_close() deep-copies picker state before closing - restore_from_state() recreates UI from saved snapshot - M.close() overrides the wired close to save state then call close_windows - M.resume(), M.resume_find_files(), M.resume_live_grep() public API - Per-mode saved state (find_files vs live_grep) In layout_manager.lua: - Extracted close_windows() as the low-level cleanup - close() now delegates to close_windows() In main.lua: - find_files and live_grep support opts.resume - M.resume() public API for :FFFResume command plugin/fff.lua: - :FFFResume user command
2a2f715 to
d36ef1b
Compare
|
@dmtrKovalenko i've rebased main, please help take a look when u have time! |
dmtrKovalenko
left a comment
There was a problem hiding this comment.
I see that it works, I'll merge it to unblock just will ask @gustav-fff to create a new PR on top of main with the suggestions I have applied
I'll take it from there
| local snapshot = vim.deepcopy(M.state) | ||
|
|
||
| local fuzzy = require('fff.core').ensure_initialized() | ||
| local ok, base_path = pcall(fuzzy.get_base_path) |
There was a problem hiding this comment.
We should be using state from config here but it's okay
|
|
||
| -- Resume state: saved snapshots of closed pickers for the resume feature. | ||
| --- @type table|nil Saved state from last file picker (find_files) session | ||
| local last_file_picker_state = nil |
There was a problem hiding this comment.
Can we put this to a one object
| ---@return boolean|nil true if a picker was resumed, false otherwise | ||
| function M.resume() | ||
| if M.state.active then | ||
| vim.notify('FFF: close the current picker before resuming', vim.log.levels.INFO) |
There was a problem hiding this comment.
Should we do this? Can we enforce recreation it if the user simply wants to get previous results?
Summary
Implements the ability to resume the last closed picker, similar to Telescope's
resume(). The full picker state (query, results, cursor, mode, pagination, etc.) is saved before closing and restored on resume.Changes
lua/fff/picker_ui.lua: Core resume logicsave_state_and_close()— saves full picker state before closing, routed to mode-specific slot (file vs grep)restore_from_state()— shared helper to restore picker from a saved snapshotM.resume()— resumes the most recently closed picker (any mode)M.resume_find_files(opts)— resumes last file picker, falls back tofind_filesM.resume_live_grep(opts)— resumes last grep picker, falls back tolive_greplua/fff/main.lua: Public APIfind_files({ resume = true })— resume last file picker or open newlive_grep({ resume = true })— resume last grep picker or open newresume()— resume last closed picker (generic)plugin/fff.lua: User command:FFFResume— resume last closed pickerUsage
Demo
Screen.Recording.2026-05-03.at.08.18.29.mov
Closes #405