diff: accepted text differs from :w in corner cases of 'fileformat' and 'fileformats'

未关闭
#581 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
lua, neovim
领域
devtools

调研方向

Start with the diff acceptance code and the neovim_writes oracle in tests/integration/diff_accept_crlf_spec.lua. Compare proposal splitting and joining against readfile and :w for the listed fileformat and fileformats cases, including cases 4 and 5 whose scope still awaits a maintainer decision. Done means accepted text matches :w across the reported cases and the integration tests cover them.

由索引模型根据 Issue 内容生成。

描述

needs-triage

The text that a split-layout diff accepts can differ from what :w writes for the same buffer in some corner cases of 'fileformat' and 'fileformats'. Each case below exists on main before #577 too. #577 fixes the common cases (CRLF proposals under the default 'fileformats', and an unedited proposal under any 'fileformats') and leaves these for a follow-up.

  1. ff=mac with a CR inside a line: :w writes that CR as NL, the accepted text keeps it. "a\rb\n" then :setlocal ff=mac gives "a\rb\r", while :w gives "a\nb\r". main joined with LF, which is also wrong. Codex flagged this on #577 (diff.lua, "Translate embedded CR bytes before joining Mac lines").
  2. set ffs=unix,mac: Neovim reads, for example, "a\r\nb\r\r\n" as mac, but the diff never detects mac. In 24 ff=mac edit cases, main's answer equals a file-read oracle and #577's does not. Both differ from :w of the same buffer.
  3. Empty proposal, then typed lines: 'eol' stays off (#542), so Gox gives "\nx", while :w of an empty file gives "\nx\n".
  4. 'fileformats' starting with dos and a proposal with no LF ("", "a", "a\r"): Neovim reads it as dos, the diff keeps unix, so a typed line gets LF where :w writes CRLF.
  5. set ffs=dos (one entry): Neovim reads every file as dos, an LF file too. An LF or mixed proposal stays unix, so a typed line gets LF where :w of the file writes CRLF.

Fix direction: one function that decides 'fileformat' and splits the proposal the way readfile does (empty value: 'fileformat'; one entry: forced; several entries: dos unless a lone LF, mac when there are more CRs than LFs, the first entry when there is no LF), plus a join that translates CRs for mac. The neovim_writes oracle in tests/integration/diff_accept_crlf_spec.lua (#577) can be reused.

Evidence: a probe of 1860 cases per run on Neovim 0.12.3 and 0.8.0, under 'fileformats' unix,dos, dos,unix, unix, dos and unix,mac. Mismatches with :w left on #577 (on main): 144 (748), 184 (788), 192 (304), 516 (1104), 544 (608).

The maintainer agreed to defer items 1 and 3 (and item 2, which belongs to item 1) from the README verification run. Items 4 and 5, and item 6 in the comment below, were found later and still wait for the maintainer's decision: fix them in this run or defer them here.


Generated with xum • Model: anthropic:claude-opus-5-5 • Thinking: high

主要语言
Lua
星标
3.2k
派生
223
平均合并
6 小时 7 分钟
30 天内合并 PR
210

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

coder/claudecode.nvim 的其他 Issue

查看 coder/claudecode.nvim 的全部 Issue

相似的 Issue

更多 Lua Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。