Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ All plugin code lives under `lua/fude/`. The plugin entry point is `plugin/fude.
| `reload_timer` | init | init |
| `reloading` | init | init |
| `gitsigns_reset` | init, scope | init |
| `iwhite` | init | init |
| `sidepanel` | ui/sidepanel | ui/sidepanel |

**高リスクフィールド**(多数のモジュールから参照):
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ PR code review inside Neovim. Review GitHub pull requests without leaving your e
| `:FudeCopyPRURL` | Copy PR URL to clipboard |
| `:FudeReviewReload` | Reload review data from GitHub |
| `:FudeReviewToggleCommentStyle` | Toggle comment display style (virtualText/inline) |
| `:FudeReviewToggleWhitespace` | Toggle whitespace diff ignore (iwhite) |
| `:FudeReviewToggleGitsigns` | Toggle gitsigns between PR base and HEAD |
| `:FudeCreatePR` | Create draft PR from template |

Expand Down
7 changes: 7 additions & 0 deletions doc/fude.txt
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,13 @@ Using lazy.nvim: >lua
or viewed/reviewed state is toggled.
Configurable via `sidepanel` options. Requires an active session.

:FudeReviewToggleWhitespace *:FudeReviewToggleWhitespace*
Toggle whitespace diff ignore (iwhite) on and off.
When enabled, whitespace-only changes are hidden from the diff view.
Execute again to show whitespace changes.
The setting is automatically restored when review mode stops.
Requires an active review session.

:FudeReviewToggleGitsigns *:FudeReviewToggleGitsigns*
Toggle gitsigns base between PR base and HEAD.
By default during review mode, gitsigns uses the PR base (or commit
Expand Down
2 changes: 2 additions & 0 deletions lua/fude/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ M.state = {
reload_timer = nil, -- vim.uv.new_timer() handle for auto-reload
reloading = false, -- Guard flag to prevent concurrent reloads
gitsigns_reset = false, -- true: HEAD表示(一時的に元のワークツリー状態)、false: PRベース表示
iwhite = false, -- true: diffopt に iwhite を追加して空白差分を無視
sidepanel = nil, -- { win, buf, scope_entries, file_entries, section_map, augroup }
}

Expand Down Expand Up @@ -178,6 +179,7 @@ function M.reset_state()
reload_timer = nil,
reloading = false,
gitsigns_reset = false,
iwhite = false,
sidepanel = nil,
}
end
Expand Down
20 changes: 20 additions & 0 deletions lua/fude/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -708,6 +708,26 @@ function M.restore_gitsigns_base()
end
end

--- Toggle whitespace diff ignore (iwhite).
--- When enabled, whitespace-only changes are hidden from the diff view.
function M.toggle_iwhite()
local state = config.state
if not state.active then
vim.notify("fude.nvim: Not active", vim.log.levels.WARN)
return
end
Comment on lines +713 to +718
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

この実装だと config.opts.diffopt = nil(ユーザー既定の diffopt を維持する設定)の場合に state.original_diffopt が保存されないため、toggle_iwhite() による diffopt 変更が :FudeReviewStop で復元されずに残ります。toggle_iwhite() 実行前(または review start 時)に必ず original_diffopt を退避するようにして、停止時に確実に元へ戻るようにしてください。

Copilot uses AI. Check for mistakes.

if state.iwhite then
state.iwhite = false
vim.opt.diffopt:remove("iwhite")
vim.notify("fude.nvim: Whitespace diff ON", vim.log.levels.INFO)
else
state.iwhite = true
vim.opt.diffopt:append("iwhite")
Comment on lines +720 to +726
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

state.iwhite の初期値が常に false のため、ユーザーの元の diffopt に既に iwhite が入っているケースでトグル挙動が破綻します(1回目の実行で何も変わらず、2回目でユーザー設定の iwhite を削除してしまう)。トグルは vim.o.diffopt(または vim.opt.diffopt:get())の現在値から実状態を判定して state.iwhite を同期するか、セッション開始時点の diffopt を基準に on/off するようにしてください。

Suggested change
if state.iwhite then
state.iwhite = false
vim.opt.diffopt:remove("iwhite")
vim.notify("fude.nvim: Whitespace diff ON", vim.log.levels.INFO)
else
state.iwhite = true
vim.opt.diffopt:append("iwhite")
local diffopt = vim.opt.diffopt:get()
local has_iwhite = false
for _, opt in ipairs(diffopt) do
if opt == "iwhite" then
has_iwhite = true
break
end
end
-- Sync internal state with the actual current diffopt value before toggling.
state.iwhite = has_iwhite
if has_iwhite then
vim.opt.diffopt:remove("iwhite")
state.iwhite = false
vim.notify("fude.nvim: Whitespace diff ON", vim.log.levels.INFO)
else
vim.opt.diffopt:append("iwhite")
state.iwhite = true

Copilot uses AI. Check for mistakes.
vim.notify("fude.nvim: Whitespace diff ignored", vim.log.levels.INFO)
end
end
Comment on lines +711 to +729
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

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

toggle_iwhite() の追加に対するテストが見当たりません。diffopt の変更/復元(特に stop 時に元へ戻ること、既に iwhite が入っている初期状態でのトグル挙動)を tests/fude/init_integration_spec.lua 等でカバーするテストを追加してください。

Copilot generated this review using guidance from repository custom instructions.

--- Toggle gitsigns base between PR base and HEAD.
--- When toggled to HEAD, gitsigns uses HEAD as the base to show changes in the working tree.
--- When toggled back, gitsigns uses the PR base as the base to show changes in the working tree.
Expand Down
4 changes: 4 additions & 0 deletions plugin/fude.lua
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,10 @@ vim.api.nvim_create_user_command("FudeReviewToggleCommentStyle", function()
require("fude.ui").refresh_extmarks()
end, { desc = "Toggle comment display style (virtualText/inline)" })

vim.api.nvim_create_user_command("FudeReviewToggleWhitespace", function()
require("fude").toggle_iwhite()
end, { desc = "Toggle whitespace diff (iwhite)" })

vim.api.nvim_create_user_command("FudeReviewToggleGitsigns", function()
require("fude").toggle_gitsigns()
end, { desc = "Toggle gitsigns between PR base and HEAD" })
Expand Down
Loading