Skip to content

actions fixes#2666

Merged
phanen merged 5 commits intomainfrom
actions
Apr 15, 2026
Merged

actions fixes#2666
phanen merged 5 commits intomainfrom
actions

Conversation

@phanen
Copy link
Copy Markdown
Collaborator

@phanen phanen commented Apr 15, 2026

  • fix(actions): bufhidden is changed on failure
  • refactor(actions): dryer
  • refactor(actions): will_replace_curbuf is confusing

Summary by CodeRabbit

  • Refactor
    • Internal buffer and command handling reorganized; user-facing behavior unchanged.
  • Tests
    • Added hooks and conditional retries to improve stability and reduce flakes across platforms.
  • Chores
    • Increased test timeouts for CI and switched CI jobs to use a slimmer runner environment.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bb52f988-c05f-409a-890e-678e3f8bebcc

📥 Commits

Reviewing files that changed from the base of the PR and between 918adfc and bdbd162.

📒 Files selected for processing (7)
  • .github/workflows/lint.yaml
  • .github/workflows/luarocks-release.yaml
  • .github/workflows/sync_remote.yaml
  • .github/workflows/vimdoc.yaml
  • lua/fzf-lua/test/helpers.lua
  • tests/api_spec.lua
  • tests/win_spec.lua
✅ Files skipped from review due to trivial changes (5)
  • .github/workflows/lint.yaml
  • .github/workflows/luarocks-release.yaml
  • .github/workflows/vimdoc.yaml
  • .github/workflows/sync_remote.yaml
  • tests/api_spec.lua
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/win_spec.lua
  • lua/fzf-lua/test/helpers.lua

📝 Walkthrough

Walkthrough

Refactored buffer-opening/control flow in lua/fzf-lua/actions.lua; increased CI test wait multiplier; added post-open synchronization in tests/api_spec.lua; adjusted test retry behavior in tests/win_spec.lua; updated several GitHub Actions runners to ubuntu-slim.

Changes

Cohort / File(s) Summary
Actions / Buffer Logic
lua/fzf-lua/actions.lua
Replaced buf_edited/load_buf with is_curbuf/can_replace_buf; removed will_replace_curbuf param from set_buf and added conditional bufhidden restore; refactored vimcmd_entry to compute layoutcmd, use vim.fn.bufadd(relpath) then set_buf, tightened fzf-terminal check and cursor-setting, unified list opener dispatch, and replaced manual dedupe with vim.tbl_map/utils.list_to_map/vim.tbl_filter.
Test helper timeout
lua/fzf-lua/test/helpers.lua
Increased CI wait multiplier for child.wait_until from 2x to 3x inside M.new_child_neovim.
API tests: post-open sync
tests/api_spec.lua
Added __after_open callback to wait inside child Neovim until _G._fzf_load_called == true for several fzf_live cases.
Platform-specific test tweaks
tests/win_spec.lua
Changed MiniTest set to new_set({ n_retry = not helpers.IS_LINUX() and 5 or nil }) to allow retries on non-Linux platforms.
CI workflows
.github/workflows/...
lint.yaml, luarocks-release.yaml, sync_remote.yaml, vimdoc.yaml
Switched GitHub Actions runners from ubuntu-latest/ubuntu-22.04 to ubuntu-slim for multiple jobs; no other workflow logic changed.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant FZF as "fzf window"
    participant Actions as "actions.lua"
    participant Buffer as "Vim Buffer"
    participant Window as "Vim Window / Opener"

    User->>FZF: selects entry
    FZF->>Actions: call vimcmd_entry(entry, opts)
    Actions->>Actions: compute layoutcmd (split/open/ctag handling)
    Actions->>Buffer: call vim.fn.bufadd(relpath) -> bufnr
    Actions->>Buffer: check is_curbuf / can_replace_buf
    alt replaceable
        Actions->>Window: set_buf(bufnr) (may preserve/restore bufhidden)
    else not replaceable
        Actions->>Window: open new buffer/window via layoutcmd
    end
    Actions->>Window: run opener (open/split/quickfix) and set cursor/search
    Window-->>User: buffer opened / command executed
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested reviewers

  • ibhagwan

Poem

🐰
I hopped through buffers, tidy and spry,
Rewrote the paths where filenames lie.
From select to open, a nimble dance,
One small hop brings a cleaner chance.

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title 'actions fixes' is vague and generic, using a non-descriptive term that doesn't convey specific information about the changeset. Use a more descriptive title that captures the main fix or refactoring, such as 'Fix buffer state handling in actions' or 'Refactor buffer management and window replacement logic'.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch actions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@phanen
Copy link
Copy Markdown
Collaborator Author

phanen commented Apr 15, 2026

this should be a bug: :call nvim_buf_set_text(0, 0, 0, 0, 0, []) | FzfLua files, actions cannot open new buffer

@ibhagwan
Copy link
Copy Markdown
Owner

ibhagwan commented Apr 15, 2026

On another note the CI is so flakey it’s so annoying I have to run jobs again and again to see green lol

phanen added 4 commits April 15, 2026 20:33
fix: set_buf fail but no errmsg when buf is modified && unamed && empty
fix: remove opts.silent guard for non-annoying msg
will_replace_buf seems to mean "wipe unnamed empty buffers"
`:call nvim_buf_set_text(0, 0, 0, 0, 0, []) | FzfLua files`
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@lua/fzf-lua/actions.lua`:
- Around line 323-325: The comparator in lua/fzf-lua/actions.lua compares a.col
directly which can nil-crash; update the sort comparator (the block comparing
a.filename, a.lnum, a.col) to normalize missing column values before comparing
(e.g., set local ac = a.col or 0 and local bc = b.col or 0 or use tonumber on
each) and then compare ac < bc; keep the earlier filename and lnum comparisons
unchanged and ensure the comparator always returns a boolean.
- Line 258: The early-return that used to guard terminal buffers was reduced to
only checking filetype (vim.bo.ft == "fzf"); restore a terminal-buffer guard so
the function exits for terminal buffers too. Update the conditional in
lua/fzf-lua/actions.lua (the if vim.bo.ft == "fzf" then return end line) to also
check buftype (e.g., if vim.bo.ft == "fzf" or vim.bo.buftype == "terminal" then
return end) so terminal-mode incompatible operations are skipped.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ef8d1ca3-4532-4580-afb8-d31a6e3c4640

📥 Commits

Reviewing files that changed from the base of the PR and between 6048a5b and a683139.

📒 Files selected for processing (1)
  • lua/fzf-lua/actions.lua

Comment thread lua/fzf-lua/actions.lua
if utils.is_term_buffer(0) and vim.bo.ft == "fzf" then
return
end
if vim.bo.ft == "fzf" then return end
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Terminal-buffer guard was narrowed too much

Line 258 now only checks vim.bo.ft == "fzf". This can let execution continue in other terminal buffers and hit terminal-mode-incompatible operations later in the function. Re-adding a terminal-buffer guard avoids this regression.

💡 Suggested fix
-      if vim.bo.ft == "fzf" then return end
+      if vim.bo.ft == "fzf" or utils.is_term_buffer(0) then return end
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if vim.bo.ft == "fzf" then return end
if vim.bo.ft == "fzf" or utils.is_term_buffer(0) then return end
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lua/fzf-lua/actions.lua` at line 258, The early-return that used to guard
terminal buffers was reduced to only checking filetype (vim.bo.ft == "fzf");
restore a terminal-buffer guard so the function exits for terminal buffers too.
Update the conditional in lua/fzf-lua/actions.lua (the if vim.bo.ft == "fzf"
then return end line) to also check buftype (e.g., if vim.bo.ft == "fzf" or
vim.bo.buftype == "terminal" then return end) so terminal-mode incompatible
operations are skipped.

Comment thread lua/fzf-lua/actions.lua
Comment on lines +323 to +325
if a.filename ~= b.filename then return a.filename < b.filename end
if a.lnum ~= b.lnum then return a.lnum < b.lnum end
return a.col < b.col
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Potential sort crash when col is missing

At Line 325, return a.col < b.col can error when either side is nil (common for entries without a column). Please normalize col before sorting.

💡 Suggested fix
-    return a.col < b.col
+    return (a.col or 0) < (b.col or 0)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if a.filename ~= b.filename then return a.filename < b.filename end
if a.lnum ~= b.lnum then return a.lnum < b.lnum end
return a.col < b.col
if a.filename ~= b.filename then return a.filename < b.filename end
if a.lnum ~= b.lnum then return a.lnum < b.lnum end
return (a.col or 0) < (b.col or 0)
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@lua/fzf-lua/actions.lua` around lines 323 - 325, The comparator in
lua/fzf-lua/actions.lua compares a.col directly which can nil-crash; update the
sort comparator (the block comparing a.filename, a.lnum, a.col) to normalize
missing column values before comparing (e.g., set local ac = a.col or 0 and
local bc = b.col or 0 or use tonumber on each) and then compare ac < bc; keep
the earlier filename and lnum comparisons unchanged and ensure the comparator
always returns a boolean.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/api_spec.lua (1)

207-209: Remove redundant load wait in this __after_open hook.

On Line 207–209, this wait duplicates the framework-level synchronization: helpers.FzfLua.* already waits for _G._fzf_load_called == true before running __after_open (see lua/fzf-lua/test/helpers.lua, around Line 334 and Line 350). Keeping both adds avoidable delay and can worsen timing flakiness.

♻️ Proposed simplification
-          __after_open = function()
-            child.wait_until(function() return child.lua_get([[_G._fzf_load_called]]) == true end)
-          end,
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/api_spec.lua` around lines 207 - 209, The __after_open hook currently
calls child.wait_until checking child.lua_get([[_G._fzf_load_called]]), which
duplicates the framework-level synchronization already performed by
helpers.FzfLua.*; remove that child.wait_until(...) block from the __after_open
hook in tests/api_spec.lua so the test relies on the existing helper wait and
avoids redundant delays and flakiness.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@tests/api_spec.lua`:
- Around line 207-209: The __after_open hook currently calls child.wait_until
checking child.lua_get([[_G._fzf_load_called]]), which duplicates the
framework-level synchronization already performed by helpers.FzfLua.*; remove
that child.wait_until(...) block from the __after_open hook in
tests/api_spec.lua so the test relies on the existing helper wait and avoids
redundant delays and flakiness.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0dc4a250-e6c3-40a3-8483-238aea49733c

📥 Commits

Reviewing files that changed from the base of the PR and between b888086 and 918adfc.

📒 Files selected for processing (3)
  • lua/fzf-lua/test/helpers.lua
  • tests/api_spec.lua
  • tests/win_spec.lua
✅ Files skipped from review due to trivial changes (1)
  • tests/win_spec.lua
🚧 Files skipped from review as they are similar to previous changes (1)
  • lua/fzf-lua/test/helpers.lua

ci: use ubuntu-slim on small job
@phanen
Copy link
Copy Markdown
Collaborator Author

phanen commented Apr 15, 2026

Move lint/vimdoc job to ubuntu-slim. https://docs.github.com/en/actions/reference/runners/github-hosted-runners#single-cpu-runners
Not sure if this helpful for ci load balance, but it's harmless and save more electricity.

@phanen phanen merged commit be79dea into main Apr 15, 2026
11 checks passed
@phanen phanen deleted the actions branch April 15, 2026 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants