Skip to content

Neovim 0.12 互換: JSON null (vim.NIL) チェックの統一#112

Merged
flexphere merged 3 commits intomainfrom
fix/vim-nil-compat
Mar 30, 2026
Merged

Neovim 0.12 互換: JSON null (vim.NIL) チェックの統一#112
flexphere merged 3 commits intomainfrom
fix/vim-nil-compat

Conversation

@flexphere
Copy link
Copy Markdown
Owner

概要

Neovim 0.12 では vim.json.decode が JSON null を vim.NIL として返すようになった。fude.nvim の複数箇所で nil のみチェックしており vim.NIL(truthy)を考慮していなかったため、is_null ヘルパーで統一的に修正。Neovim 0.11/0.12 両対応。

変更内容

  • lua/fude/util.lua を新規作成し、is_null(v) ヘルパーを定義(nilvim.NIL の両方を検出)
  • comments/data.lua の 6 箇所を is_null で置き換え:
    • line_from_diff_hunk: 引数の null チェック
    • build_comment_map: line フォールバックと null ガード
    • get_comment_thread: in_reply_to_id のルート判定(2箇所)
    • build_pending_comments_from_review: line/start_line フォールバック
    • get_reply_target_id: in_reply_to_id の truthy チェック
    • is_outdated_comment: is_null で簡潔化
  • comments/sync.luafetch_comments 内で c.line/c.original_line の null チェックを修正

テスト計画

  • 既存テスト全パス (make all)
  • 新規テスト追加: tests/fude/util_spec.lua (8テスト), tests/fude/comments_spec.lua (8テスト追加)
  • 手動確認: Neovim 0.12 環境で PR レビューコメントの表示・ナビゲーション

備考

  • pull_request_review_id == pending_review_id の比較は変更不要と判断。vim.NIL == numberfalse を返し、「ペンディングレビューに属さない」という正しい結果になるため
  • ui/format.lua は既に type(entry.line) == "number" で型チェック済みのため変更不要

Generated with Claude Code

flexphere and others added 3 commits March 31, 2026 01:27
…ompat

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings March 30, 2026 16:28
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Neovim 0.12 で vim.json.decode が JSON nullvim.NIL(truthy)として返す変更に対応するため、nil のみを前提にした既存の null 判定を is_null ヘルパーに統一し、0.11/0.12 両対応の挙動に揃えるPRです。

Changes:

  • lua/fude/util.lua を追加し、nilvim.NIL を同一視する is_null(v) を導入
  • lua/fude/comments/data.lua / lua/fude/comments/sync.luanil チェックを is_null ベースに置換し、vim.NIL の truthy 罠を回避
  • vim.NIL ケースをカバーするテストを追加(tests/fude/util_spec.luatests/fude/comments_spec.lua

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.

Show a summary per file
File Description
lua/fude/util.lua nil/vim.NIL を統一的に判定する is_null を追加
lua/fude/comments/data.lua line/original_line/in_reply_to_id 等の null 判定を is_null に統一
lua/fude/comments/sync.lua pending review comment の line 解決条件を is_null で正しく判定
tests/fude/util_spec.lua is_null の単体テストを追加
tests/fude/comments_spec.lua vim.NIL を含むコメントデータのフォールバック/スキップ等のテストを追加
CLAUDE.md util.luais_null の役割を開発ドキュメントに追記

@flexphere flexphere marked this pull request as ready for review March 30, 2026 16:31
@flexphere flexphere merged commit ae8e01d into main Mar 30, 2026
9 checks passed
@flexphere flexphere deleted the fix/vim-nil-compat branch March 30, 2026 16:32
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