Skip to content

fix: commit scope突入時にgitsignsのper-bufferベースを再適用する - #168

Closed
kyu08 wants to merge 1 commit into
mainfrom
fix/commit-scope-gitsigns-base
Closed

fix: commit scope突入時にgitsignsのper-bufferベースを再適用する#168
kyu08 wants to merge 1 commit into
mainfrom
fix/commit-scope-gitsigns-base

Conversation

@kyu08

@kyu08 kyu08 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

概要

:FudeReviewScope で特定commitに絞ると、gitsignsのgutterがそのcommitの変更行だけでなくPR全体のdiff(全行追加)を表示するバグを修正する。

Fixes #167

原因

gitsignsの change_base(base, false)(バッファローカル)はグローバルベースより優先される。full PR scope時に各バッファへPRベースがローカル設定されるが、commit scopeへ切り替える apply_commit_scope はグローバルベースを sha^ に変えるだけで、既存バッファのローカルベースを掃除していなかった。結果、表示中バッファは古いPRベースとの差分を描き続けていた。

previewの縦分割(diffthis)はscopeごとにベース内容を再取得するため正しく表示され、]c/[c のhunkジャンプも正しく着地する。壊れていたのはgitsignsのgutterのみで、原因の切り分けと一致する。

修正

apply_full_pr_scope と対称に、グローバルベース設定後にロード済みバッファをループして apply_gitsigns_base_for_buffer を呼び、各バッファのローカルベースを sha^ に上書きする。同関数は既にcommit scopeを判定して sha^ を使う(init_integration_spec.lua でカバー済み)。

動作確認

  • make all 通過(lint / format-check / test 44件成功、state-deps / purity / docs チェックOK)
  • headlessでのスモーク確認(後述)

When switching from full PR scope to a commit scope, only the global
gitsigns base was updated to `sha^`. Buffers already displayed during
full PR scope kept their buffer-local base (the PR base), which takes
precedence over the global one, so gitsigns rendered the whole PR diff
(all lines shown as added) instead of the single commit's changes.

Mirror `apply_full_pr_scope` by looping over loaded buffers and calling
`apply_gitsigns_base_for_buffer`, which already resolves the commit-scope
base to `sha^`, overwriting the stale buffer-local bases.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 22, 2026 01:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

:FudeReviewScope で commit scope に切り替えた際、gitsigns の gutter が PR 全体の diff を表示してしまう不具合(Issue #167)を修正し、commit scope でも「その commit に対する正しい差分表示」を保つための変更です。

Changes:

  • apply_commit_scope 実行時に、グローバル gitsigns base を sha^ に更新した後、ロード済みバッファ全てへ apply_gitsigns_base_for_buffer() を再適用してバッファローカル base を上書き
  • commit scope 時の gitsigns base 再適用について、CLAUDE.md のアーキテクチャ記述を更新

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
lua/fude/scope.lua commit scope 切替時に既存バッファの per-buffer gitsigns base を再適用し、stale な PR ベースが残る問題を解消
CLAUDE.md commit scope の gitsigns base 再適用についてドキュメントの説明を更新

Comment thread lua/fude/scope.lua
Comment on lines +677 to +681
-- Overwrite per-buffer bases left over from full PR scope: a buffer-local
-- base (set via change_base(_, false)) takes precedence over the global one,
-- so without this loop already-open buffers keep showing the PR-wide diff.
local init_mod = require("fude.init")
for _, bufnr in ipairs(vim.api.nvim_list_bufs()) do
@kyu08

kyu08 commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator Author

修正が確認できなかったが、FudeReviewDiffコマンドを使えば問題無いことに気付いたのでclose

@kyu08 kyu08 closed this Jul 22, 2026
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.

commit scope選択時にgitsignsがPR全体のdiffを表示する

2 participants