Skip to content

fix(actions): copy edits before preview#2702

Merged
ibhagwan merged 1 commit intoibhagwan:mainfrom
IlyasYOY:fix/2701
Apr 23, 2026
Merged

fix(actions): copy edits before preview#2702
ibhagwan merged 1 commit intoibhagwan:mainfrom
IlyasYOY:fix/2701

Conversation

@IlyasYOY
Copy link
Copy Markdown
Contributor

@IlyasYOY IlyasYOY commented Apr 23, 2026

Closes: #2701

Summary by CodeRabbit

  • Bug Fixes

    • Code action previews no longer mutate shared edit data, preserving the original edits when previewing multiple actions.
  • Tests

    • Added tests that validate preview behavior to prevent regressions related to edit data mutation.

@ibhagwan
Copy link
Copy Markdown
Owner

Tysm @IlyasYOY!

We’ll let code rabbit review this, if the CI passes I’ll merge it soon.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 23, 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: fb6e28f4-76fc-47cd-9d0c-e56c129e731e

📥 Commits

Reviewing files that changed from the base of the PR and between 17ef12d and 0135a48.

📒 Files selected for processing (2)
  • lua/fzf-lua/previewer/codeaction.lua
  • tests/codeaction_spec.lua
✅ Files skipped from review due to trivial changes (1)
  • lua/fzf-lua/previewer/codeaction.lua
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/codeaction_spec.lua

📝 Walkthrough

Walkthrough

A bug fix in the code action previewer prevents in-place mutations of text edits by deep-copying the edits before applying them. A new test verifies that the original edits remain unchanged after previewing.

Changes

Cohort / File(s) Summary
Code Action Previewer Fix
lua/fzf-lua/previewer/codeaction.lua
Deep-copies text_edits before passing them to vim.lsp.util.apply_text_edits, preventing the LSP utility from mutating the original edits table.
Code Action Test
tests/codeaction_spec.lua
Adds a test that constructs LSP-style overlapping edits, runs preview_action_tuple, and asserts the original text_edits table remains unchanged (deep equality check).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I copied the edits, kept the originals neat,
No in-place surprise, no mutation to greet,
The preview hops lightly and leaves things intact,
Tests give a nod — the rabbit's got your back! 🎉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: copying text edits before passing them to the preview function to prevent mutations.
Linked Issues check ✅ Passed The PR fixes the LSP code action breakage caused by fzf-lua's ui.select registration by deep-copying text edits before preview, preventing unwanted mutations [#2701].
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the issue: modifying the preview function to copy edits and adding a test to validate the fix.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@ibhagwan
Copy link
Copy Markdown
Owner

Fix this lint and we’re gtg

tests/codeaction_spec.lua:40:3 [Warning] Duplicate field `lsp_get_clients`. (duplicate-set-field)
      utils.lsp_get_clients = function(opts)

Since this is a shim adding a disable warning the line above should suffice.

@IlyasYOY
Copy link
Copy Markdown
Contributor Author

@ibhagwan sorry, missed the lint step, fixed and repushed.

I suppressed diagnostics, because I need to set the field to create a stub for test.

@ibhagwan ibhagwan merged commit 58f52b7 into ibhagwan:main Apr 23, 2026
9 checks passed
@ibhagwan
Copy link
Copy Markdown
Owner

Tysm @IlyasYOY for your effort!

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.

Bug: vim.ui.select using fzf-lua breaks the LSP code action

2 participants