neomacs icon indicating copy to clipboard operation
neomacs copied to clipboard

[Bug]: cursor position wrong

Open definepi opened this issue 6 days ago • 34 comments

Bug summary

还是我的doom配置,我发现有时光标位置和当前实际所在位置不一致,我抓的log最后10多秒,我在文件的第98行住下移动到99行,但光标却在第100行(行首),我再从99移动到100行,光标还是在第100行(非行首)。

neomacs-debug.zip

Steps to reproduce

No response

Expected behavior

No response

Neomacs --version output

Neomacs 0.0.21
Git commit: 9ca34ffd1c9450183825ab916cac313729bdf419
Source date: 2026-11-26T04:07:21.000000000-05:00
Build: release for x86_64-unknown-linux-gnu with rustc 1.96.1
Standalone Rust binary for Neomacs (no C dependency)

Platform

Linux (Wayland)

Install source

Prebuilt release asset (downloaded from Releases)

Extra context

No response

definepi avatar Nov 26 '26 13:11 definepi

谢谢报告,也谢谢你附上 log。先说结论:这份 log 里没有任何 redisplay / 窗口 / 光标状态记录,所以它现在还定不了因 —— 284,411 行里有 156,108 行是 Cranelift JIT 的 IR dump,其余基本是 INFO 级的消息(load、msg 输出、命令循环 span)。我检索了 window_start / vscroll / point= / redisplay / cursor_rect / frame_geometry 这些键,一条都没有。

这是我们这边的缺口,不只是你的 log 问题:用户报显示类 bug 时,debug bundle 里应该带出光标/窗口/scroll 状态。我会把「debug bundle 增加显示状态快照」作为改进项跟进。

我对现象的理解(请确认)

  • 在第 98 行按 C-n 到 99 行:实际 point 在 99,但光标画在第 100 行行首。
  • 再 C-n 到 100 行:光标回到第 100 行,但不在行首。

也就是说光标被画到了错误的行,而且和 point 差一行 —— 这更像「光标位置更新滞后/错位」,而不是 point 本身算错。

三个问题,能极大缩小范围

  1. 在 d9813b08af 上还能复现吗? 你用的是 9ca34ffd1c,之后有两个 display 相关的改动进了主分支(Wayland PointerEntered 处理、18 个 Linux GUI 行的状态断言改造,以及 scroll coverage 的重复计算消除)。如果在 d9813b08af 上没有了,我们就拿到了区间;如果还在,也是有用信息。

  2. display-line-numbers-mode 是不是开着? 在光标看起来「错行」的那一刻,请在同一个位置求值下面两行,把结果贴出来:

    (list (line-number-at-pos) (what-line) (window-start) (window-end))
    
    • 如果 (line-number-at-pos) 就是 99 而光标画在 100 行 → 是绘制错位;
    • 如果它是 100 → 是 C-n 之后 point 真的多走了一行。 这两种是完全不同的 bug,方向不同。
  3. 按一次 C-l(recenter-top-bottom)或 M-x redraw-display 之后,光标会回到正确位置吗? 如果会 → 是「本帧重绘时用了旧的光标行」,问题在重绘路径; 如果不会 → 问题在窗口/光标状态本身。

另外一个补充问题:这个文件当时是 189 行 / 11,693 字符(log 里最后一次写盘的 msg 显示 .local/etc/workspaces/autosave 189L, 11693C)。这么小的文件不存在 scroll 边界问题,所以「光标错一行」几乎可以排除大 buffer 路径 —— 更可能是 doom 的行号/光标装饰(如 hl-line、cursor-type、beacon、evil 之类)与我们的光标绘制叠加。如果 emacs -Q 下不复现、只有 doom 配置下复现,请也告诉我,这会直接指向 overlay/装饰路径。

我们这边会做的

  • 先按上面的信息定位是「point 错」还是「绘制错」;
  • 同时把 display 状态加进 debug bundle,这样下次同类报告能直接看数据;
  • 修好后我会在这里贴出修复提交,并请你在同一份配置上复验。

再次感谢 —— 你几次报告的质量都很高,这类「差一行」的问题如果没有你的 log 和复现方式,我们很难自己撞见。

eval-exec avatar Nov 26 '26 13:11 eval-exec

@neomacs-agent neomacs 依赖的 cranelift 的日志默认是 INFO 级别的吗?有没有办法默认不打印,或者让改成 DEBUG 级别?

eval-exec avatar Nov 26 '26 15:11 eval-exec

不是 INFO,Neomacs 的默认日志级别是 warn。

当前 main 的初始化在 crates/neovm-value/src/logging.rs:

EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn"))

也就是说 RUST_LOG 未设置或无法解析时,只输出 WARN/ERROR。你那份 log 里出现大量 INFO 和 IR dump,说明抓日志时的环境设置了 RUST_LOG=info/debug/trace(或用了会设置它的调试脚本/开发 shell),不是默认行为。可以先检查 env | grep RUST_LOG。

另外,cranelift-codegen 0.134.3 本身几乎没有 INFO 级日志:主要是 debug(编译统计、timing)和 trace(完整 CLIF dump);完整 CLIF trace 只在 debug 构建或启用 trace-log feature 时才会编译进来。如果 release 构建里看到完整 IR dump,更可能是 NEOVM_JIT_DUMP_CLIF / NEOVM_JIT_DUMP_OPT 写出的文件被一起打包,或抓取脚本把级别开到了 trace。看日志行里的 target 就能确认来源。

控制方式只有环境变量(Lisp 里没有对应开关),在启动 Neomacs 的环境里设置:

# 全部关闭
RUST_LOG=off neomacs

# 保留 Neomacs 的 warn/info,只关 cranelift 和 regalloc
RUST_LOG=warn,cranelift_codegen=off,cranelift_frontend=off,cranelift_jit=off,regalloc2=off neomacs
RUST_LOG=info,cranelift_codegen=off,regalloc2=off neomacs

# 单独把 cranelift 调到 DEBUG(注意 DEBUG 比 INFO 更啰嗦,不是更安静)
RUST_LOG=warn,cranelift_codegen=debug neomacs

# 只关某个模块
RUST_LOG=warn,cranelift_codegen::timing=off neomacs

注意几点:

  • 级别顺序是 off < error < warn < info < debug < trace。想更安静请用 warn/error/off;debug 会输出更多。
  • target 名用下划线形式,例如 cranelift_codegen、regalloc2,不是 cranelift-codegen。
  • GUI 默认把日志写到 stdout;TUI(-nw)默认根本不输出日志,除非设置了 NEOMACS_LOG_FILE(旧别名 NEOMACS_LOG_TO_FILE=1)。NEOMACS_LOG_FILE 只改输出位置,不改级别;RUST_LOG=off 才会连文件一起关掉。
  • 如果只是给 #855 抓一份干净的 log:用 RUST_LOG=error,neovm=info,neomacs=info 保留 Neomacs 自己的关键消息,同时 cranelift_codegen=off,regalloc2=off,并 unset NEOVM_JIT_DUMP_CLIF / NEOVM_JIT_DUMP_OPT。

如果方便,把 IR dump 那几行的完整前缀(时间、level、target)贴一下,我可以确认是哪一路输出,并给出只关它的精确 RUST_LOG。

neomacs-agent[bot] avatar Nov 26 '26 15:11 neomacs-agent[bot]

默认级别已经不是 INFO,而是 warn。当前代码在 crates/neovm-value/src/logging.rs:173:

EnvFilter::try_from_default_env().unwrap_or_else(|_| EnvFilter::new("warn"))

RUST_LOG 未设置或无法解析时只输出 WARN/ERROR。你那份 log 里出现 INFO 和大量 IR dump,说明抓日志时的环境里有 RUST_LOG=info/debug/trace(或调试脚本设置了它),不是 Neomacs 的默认值。先确认:

env | grep -i RUST_LOG
env -u RUST_LOG neomacs    # 验证去掉环境变量后是否安静

如果希望默认就关闭 cranelift 日志,把针对 target 的规则写进同一个 RUST_LOG,并固定在启动环境里:

# 全局 warn;cranelift/regalloc 只保留 error(推荐,仍能看见真正的 JIT 失败)
export RUST_LOG=warn,cranelift_codegen=error,cranelift_frontend=error,cranelift_jit=error,regalloc2=error

# 完全关闭 cranelift/regalloc
export RUST_LOG=warn,cranelift_codegen=off,cranelift_frontend=off,cranelift_jit=off,regalloc2=off

# 保留 Neomacs 的 INFO,但 cranelift 默认关闭
export RUST_LOG=info,cranelift_codegen=off,regalloc2=off

# 只想把 cranelift 调到 DEBUG(注意 DEBUG 比 INFO 更啰嗦)
export RUST_LOG=warn,cranelift_codegen=debug

持久化位置:

  • 终端启动:写进 ~/.bashrc、~/.zshrc 或 config.fish;
  • Wayland/桌面会话:~/.config/environment.d/*.conf(systemd user 环境),或桌面文件里写 Exec=env RUST_LOG=... neomacs;
  • 只想影响一次运行:在命令前加变量。

补充说明:

  • 级别顺序是 off < error < warn < info < debug < trace。想更安静用 warn/error/off,不要用 debug;debug 会输出更多。
  • target 名用下划线形式:cranelift_codegen、regalloc2,不是 cranelift-codegen。
  • RUST_LOG=off 会把 Neomacs 自己的日志也一起关掉;只关 cranelift 请用上面的 per-target 形式。
  • TUI(-nw)默认没有日志 writer,除非设置了 NEOMACS_LOG_FILE。NEOMACS_LOG_FILE / NEOMACS_LOG_TO_FILE 只改变输出位置,不改变级别。
  • cranelift-codegen 0.134.3 本身几乎没有 INFO 级日志:主要是 DEBUG(编译统计/timing)和 TRACE(完整 CLIF dump);完整 CLIF trace 只在 debug 构建或启用 trace-log feature 时才编译进来。如果在 release 构建里看到完整 IR dump,先检查是不是 NEOVM_JIT_DUMP_CLIF / NEOVM_JIT_DUMP_OPT 写出的文件,或者调试脚本把级别开到了 trace。
  • 目前没有 Lisp 变量或配置文件控制日志级别,也没有“内置默认屏蔽 cranelift”的产品级开关,只有 RUST_LOG。如果希望即使外部设置 RUST_LOG=debug 也默认屏蔽 cranelift,需要改 make_env_filter 或增加一个 Neomacs 专用变量(例如 NEOMACS_LOG);这会掩盖 JIT 诊断,需要明确取舍,我可以做这个改动。

neomacs-agent[bot] avatar Nov 26 '26 15:11 neomacs-agent[bot]

这条评论和上面两条回复是同一个问题(评论编辑后再次触发)。答案不变,这里只补充“默认不打印”这一点:

  • Neomacs 默认已经是 warn,而 cranelift-codegen 自身的记录主要是 DEBUG/TRACE,所以默认不会打印。如果你仍然看到日志,说明启动环境里设置了 RUST_LOG。先确认:
    env | grep -i RUST_LOG
    env -u RUST_LOG neomacs
    
  • 要保证“即使外部 RUST_LOG=info/debug,cranelift 也默认不打印”,把 per-target 规则固定进启动环境:
    export RUST_LOG=warn,cranelift_codegen=off,cranelift_frontend=off,cranelift_jit=off,regalloc2=off
    
    如果只想保留真正的错误:
    export RUST_LOG=warn,cranelift_codegen=error,regalloc2=error
    
  • “改成 DEBUG 级别”:cranelift 的记录本来就是 DEBUG/TRACE;要显示它们用
    export RUST_LOG=warn,cranelift_codegen=debug
    
    注意 DEBUG 比 INFO 更啰嗦。如果你看到的是 INFO 级 IR,那不是 cranelift-codegen 的 logger(它 0.134.3 没有 INFO 记录),更可能是 regalloc2 的 verbose dump 或 Neomacs 自己的 target;按日志行里的 target 单独关闭即可。
  • 持久化:写进 shell profile、~/.config/environment.d/*.conf(systemd user)或桌面文件的 Exec=env RUST_LOG=... neomacs。NEOMACS_LOG_FILE 只改输出位置,不改级别。
  • 目前没有 Lisp 变量或配置文件级别的日志开关。如果要在代码层面保证 cranelift 默认不进入日志(即使外部设置 RUST_LOG=debug),需要改 crates/neovm-value/src/logging.rs 的 make_env_filter 或新增一个 Neomacs 专用变量;这会掩盖 JIT 诊断,需要明确取舍。需要的话我可以提 patch。

neomacs-agent[bot] avatar Nov 26 '26 15:11 neomacs-agent[bot]

Status update: we added the display/cursor telemetry this report was missing, and we have not been able to reproduce the one-row-off cursor with the shapes we tried. Reporting the negative result rather than closing the issue.

What now exists (landing next batch)

A tracing target, neomacs::cursor_geometry, with two DEBUG lines keyed by presentation id:

  • stage=draw, at the render thread: the layout rectangle and the drawn rectangle separately, drawn_in_row, the text area, the cursor row's materialized metrics (top/height/pixel_y/ascent/line spacing/char range/damage), the glyph occupying the cursor slot with its metrics, and the face's realized font.
  • stage=layout, at layout accept: window, buffer, window start, hscroll, vscroll, LayoutClass.

A real line from a Wayland session:

stage=draw presentation=1 window=3 charpos=9 style=FilledBox layout=(row=2 col=1 slot=2,1 x=16.0 y=85.0 w=8.0 h=17.0 ascent=13.0) drawn=(16.0,85.0 8.0x17.0) drawn_in_row=true text_area=(8.0,51.0 640.0x578.0) row=(role=Text top=85.0 h=17.0 pixel_y=34.0 ascent=13.0 spacing=0.0 chars=8..13 cursor_col=1 damage=New) glyph=char('h' x=16.0 y=85.0 baseline=98.0 w=8.0 h=17.0 ascent=13.0 face=20) face=(id=20 name=none family="Hack" size=13.0 ascent=13 descent=4) frame_char=8.0x17.0
stage=layout presentation=1 window=3 buffer=24 start=1 hscroll=0 vscroll=0 class=Full

Enable it with RUST_LOG=warn,neomacs::cursor_geometry=debug. The bug-report template will name that one command.

What we tried, and what it showed

A walk of C-n through ten line-99 shapes (empty, short, exact width, width−1, wrapped, and point on :height 2.0 / 0.5 glyphs) with line numbers and hl-line on, comparing Lisp-visible geometry against GNU Emacs 31.1 built from the pinned commit, and asserting on Neomacs that the drawn cursor is inside layout's row:

  • drawn cursors outside layout's row: 0 of 30 on X11, 0 of 30 on Wayland, including the tall and small glyph cases;
  • every post-move step matched GNU.

One caveat if you build on this: the cursor-drawing code derives its vertical position from the glyph in the cursor slot rather than from the layout row. That is the shape that would put a cursor one row low if a slot resolved to a glyph on the next row, so it is a plausible place to look — but we could not make it happen.

What would settle it

A neomacs::cursor_geometry log from a session where you can still see the problem. With it we can read the drawn rectangle against the layout rectangle directly, instead of guessing at the configuration. If you can also say which mode supplies the cursor — evil-mode's box cursor, a cursor-type override, or a package that sets line-spacing — that narrows it further.

If a fresh log shows drawn_in_row=true while the cursor still looks wrong, then the divergence is elsewhere (most likely in what gets presented, not what is computed) and the log tells us that too.

Two unrelated divergences surfaced while building this and have their own issues: frame-text-height reported one line too tall, and timer callbacks intermittently observing a stale current-buffer. Neither is this report, but both are being fixed.

neomacs-agent[bot] avatar Nov 27 '26 00:11 neomacs-agent[bot]

Follow-up, with one more round of shapes and two corrections to the previous comment.

Another round: chrome that moves the text area

The same C-n walk, now with a tab bar, a header line, line-spacing, all three together, and a mode line 1.4× the text height (as doom-modeline makes it). It was run against GNU Emacs 31.1 on X11 and Wayland.

  • Drawn cursor outside the row that holds point: 0 of 45 on each backend. The drawing path still looks correct.

  • It did find a real difference near the bottom of the window, filed as #858. With a taller mode line or line-spacing, the last body row is only partly visible. When C-n lands on it, Neomacs scrolls by one line, while GNU recenters with its default settings. After that, every C-n scrolls one more line and point stays on the bottom row.

    With a Doom-style mode line this happens on every C-n past the bottom. It is not the symptom you describe: in Neomacs, point and the drawn cursor still agree. But if what you saw was near the bottom of the window, it may be related. A fix is in progress there.

Corrections to the previous comment

  • Frame height. On closer measurement, Neomacs's default frame was one line shorter than GNU's (35 lines instead of 36). A set-frame-size issued from an init file while the first frame is still starting comes out one line taller. The default is fixed and landing. The startup case is still open.
  • Timer current-buffer. This was not a Neomacs bug. GNU Emacs 31.1 behaves the same way: a timer that runs after another timer called switch-to-buffer starts in the previous buffer. The test that suggested a difference compared two different timer chains. Nothing changes in Neomacs.

Still the best next step

A neomacs::cursor_geometry log (RUST_LOG=warn,neomacs::cursor_geometry=debug) from a session where the cursor looks wrong, once a build with it is out. It also helps to know whether the problem appears near the bottom of the window, or anywhere on screen.

neomacs-agent[bot] avatar Nov 27 '26 03:11 neomacs-agent[bot]

我准备编译最新版再试,需要我启动传什么环境变量,复现后做什么操作

darkhandz avatar Nov 27 '26 04:11 darkhandz

感谢你愿意再测一次。下面是需要的东西,尽量少步骤。

先说明一件事:neomacs-dump-display-state 这个命令和 neomacs::cursor_geometry 的采集代码是刚刚才写好的, 还没进 main(它在下一批里,几小时内会合入)。所以请等这批合入后再拉最新 main(我会在这个 issue 里贴出合入的 commit)。现在拉 main 的话,下面的 M-x neomacs-dump-display-state 会提示函数未定义。

启动

NEOMACS_DEBUG_DISPLAY_DUMP=/tmp/neomacs-display-debug.json \
NEOMACS_DIAGNOSTICS_PORT=19731 \
RUST_LOG=warn,neomacs::cursor_geometry=debug \
./target/release/neomacs -Q
  • RUST_LOG=...,neomacs::cursor_geometry=debug 必须在启动时就给,这样光标几何日志从第一帧就有记录。
  • NEOMACS_DEBUG_DISPLAY_DUMP 只是给 dump 命令的默认输出路径,随便改成你能找到的地方。

复现之后

  1. 让 bug 出现在屏幕上(光标偏移的那一帧要还在)。
  2. 运行 M-x neomacs-dump-display-state,或者菜单 Help → Dump Display Debug State(菜单方式不会弹 minibuffer, 不会把画面搅乱)。
  3. 把 /tmp/neomacs-display-debug.json 作为附件贴上来。

上传前请看一遍内容:frame_snapshot.text 里有你当时缓冲区里可见的文本,如果含私人内容请先删掉再贴。

如果能顺手回答两个问题,会省我们很多时间

  1. 光标偏移出现后,按一次 C-l(recenter-top-bottom)会不会恢复正常?
  2. 你的场景是不是「光标走到窗口底部那半行时,每次 C-n 窗口只滚一行,而不是居中原点」?我们刚发现 Neomacs 在「point 落在只露出一半的行上」时,会一行一行地滚,而 GNU 31.1 会居中(#858,已有修复)。如果你的症状是 这个,那它和光标画错一行可能是同一个根因的两个表现。

关于「只露出一半的行」

另外还有两个我们刚从你的报告里拆出来的、独立的问题,修复在路上:

  • #858:默认滚动策略下,point 落在半行时 GNU 居中、Neomacs 只滚一行。
  • #862:tab bar 显示时高度不一致(GNU 22 px,Neomacs X11 20 px / Wayland 18 px)。

它们的修复合入后,M-x neomacs-dump-display-state 生成的 bundle 会同时记录 render_path、is_animating、 animated_cursor_rect,这些正好能区分「布局把光标放错行」和「绘制把光标画错位置」。谢谢你的耐心。

neomacs-agent[bot] avatar Nov 27 '26 04:11 neomacs-agent[bot]

neomacs-dump-display-state 和 neomacs::cursor_geometry 已经合入 main 了(commit 633766b84c)。

请拉最新 main 编译,然后按下面操作:

NEOMACS_DEBUG_DISPLAY_DUMP=/tmp/neomacs-display-debug.json \
NEOMACS_DIAGNOSTICS_PORT=19731 \
RUST_LOG=warn,neomacs::cursor_geometry=debug \
./target/release/neomacs -Q

复现 bug(光标偏移的那一帧留在屏幕上)后,运行 M-x neomacs-dump-display-state,或菜单 Help → Dump Display Debug State,把 /tmp/neomacs-display-debug.json 作为附件贴上来。上传前看一眼内容:frame_snapshot.text 含你当时缓冲区里可见 的文本。

同一个 commit 里还有两处可能和你这份报告相关的修复/记录:一个是关闭视觉特效后空转重绘的问题(#857,和光标位置无关), 另外 #858 / #862 分别记录了「半行点导致每次 C-n 只滚一行」和「tab bar 高度 22 vs 20/18」两个独立差异。

如果方便,还是那两个问题:偏移出现后按 C-l 会不会恢复?你的场景是不是每次 C-n 只滚一行?

neomacs-agent[bot] avatar Nov 27 '26 05:11 neomacs-agent[bot]

neomacs-display-debug.json

recenter-top-bottom不能恢复。

darkhandz avatar Nov 27 '26 06:11 darkhandz

下面是第82行:
void i2s_spr_set(uint spr)
{
    if (i2s_dma_tx_spr != spr) {
        i2s_dma_tx_spr = spr;
    } else return;

GNU:从第82行的字母i按一下j(evil-next-visual-line),第83行背景高亮,方块光标和第83行的{重叠。 neo:从第82行的字母i按一下j(evil-next-visual-line),第83行背景高亮,方块光标在第84行的行首空白处。

Help → Dump Display Debug State是在第83行的时候执行的。

darkhandz avatar Nov 27 '26 06:11 darkhandz

收到 bundle,谢谢。先说两件确定的事,再说下一步。

这份 bundle 的关键信息是缺的,不是 dump 坏了

cursor_geometry_log 是空数组。原因是我上一条没讲清楚:neomacs::cursor_geometry 的采集 必须在启动时用 RUST_LOG 打开;M-x neomacs-dump-display-state 只能从你按下的那一刻开始记录, 它没法补上之前的帧。所以这次 bundle 里没有「布局矩形 vs 绘制矩形」,而这正是要对比的两行。

不需要重新编译,同一个 binary(633766b84c)换个启动命令就行:

RUST_LOG=warn,neomacs::cursor_geometry=debug \
NEOMACS_DEBUG_DISPLAY_DUMP=/tmp/neomacs-display-debug.json \
./target/release/neomacs

(NEOMACS_DIAGNOSTICS_PORT 这次不需要。)让光标偏移的那一帧停在屏幕上,再跑 M-x neomacs-dump-display-state, 把文件贴上来。这样 cursor_geometry_log 里会有成对的 stage=layout / stage=draw 行,可以直接读出 「布局把光标放在第几行、绘制落在哪个 y」。

这份 bundle 已经能确认的事

  • 版本正确:0.0.21 / 633766b84c,帧 1875×975,170 列 × 39 行,文本行高 25 px。
  • 光标确实在画:has_active_cursor=true、inverse_video_active=true,绘制矩形 x=63, y=525, 11×25;文本区从 y=50 到 y=920。
  • 没有动画干扰:is_animating=false,render_path=full_render。
  • presentation_lagging=true。
  • 你的 mode line 高 29 px,而正文行高 25 px。这意味着文本区 870 px 不是行高的整数倍: 最后一行只露出 20 px。这属于 #858 / #864 那一类(「点落在半行上时滚动行为与 GNU 不同」)。 如果光标偏移发生在窗口底部,优先怀疑它;如果不是,那就和它无关。

recenter-top-bottom 不能恢复这条很有用:它排除了「陈旧帧」这一类解释 —— 如果是画面没更新, C-l 会纠正。所以更像是每一帧都按同样的(错误的)映射在画。

我们在做的两件事

  1. 让 dump 自己补上这两行:先触发一次重绘、等渲染线程真的呈现了,再把几何日志写进 bundle。 这样以后你只要跑 M-x neomacs-dump-display-state,不需要任何环境变量。这个改动会先合入 main, 合入后我在这里贴 commit。
  2. 这份 bundle 里 window_end 是 0,而 window_start=3678、buffer_size=12455——字段自相矛盾, 我先按 dump 自身的缺陷排查,不拿它当证据。

提醒

frame_snapshot.text 里是你当时窗口里可见的文本。上传前可以把它清空或删改,不影响我们分析其余字段。

neomacs-agent[bot] avatar Nov 27 '26 06:11 neomacs-agent[bot]

neomacs-display-debug.json

在Help → Dump Display Debug State后,我又上下移动了一下cursor,最后停留在出问题的行,在终端Ctrl+C停止了neo的运行,复制json上传。看来cursor_geometry_log": []还是空的,等你确认后我再抓吧。

darkhandz avatar Nov 27 '26 07:11 darkhandz

更正:不是你的操作问题,是我上一条说错了。

你两次的 bundle 都显示 cursor_geometry_capture_enabled: true 而 cursor_geometry_log 为空。原因我刚核实:

neomacs::cursor_geometry 分两半——采集/打包这一半在 633766b84c 里(所以你看到了 cursor_geometry_log 这个字段、 last_presented 也确实有数据),但产生日志的那一半(渲染线程的 stage=draw、布局接受时的 stage=layout)在 fc4ebce921 feat(display): log cursor placement for display bug reports (#855) 里,而这个提交还没进 main,正在 当前批次的 gate 里。

所以在你手上的 633766b84c 上,无论 RUST_LOG 怎么设,那个数组都会是空的——没有代码往里写。我上一条说 「不用重新编译,只加环境变量」是错的,对不起。

下一步

  1. 等这批合入(正在跑最后几项,我会在这里贴 landing commit)。
  2. 拉最新 main 重新编译。
  3. 用同一条命令启动:RUST_LOG=warn,neomacs::cursor_geometry=debug NEOMACS_DEBUG_DISPLAY_DUMP=… ./target/release/neomacs
  4. 复现(偏移停在屏幕上),M-x neomacs-dump-display-state,上传。

那时 cursor_geometry_log 里会有成对的 stage=layout / stage=draw,我们就能直接把「布局把光标放第几行」和 「绘制落在哪个 y」对上。

这两份 bundle 仍然有用

第二次的帧几何是完整的:39 行、行高 25 px,光标矩形 x=118, y=450, 11×25;render_path=full_render、 is_animating=false、inverse_video_active=true。等 emitter 到位,同一个 dump 就能补上对照组。

你回答的「C-l 不能恢复」和「是不是每次 C-n 只滚一行」都已记录;后者对应 #858,已有修复在这批里。

neomacs-agent[bot] avatar Nov 27 '26 07:11 neomacs-agent[bot]

当时我有用M-x what-cursor-position记录一下位置信息,分别在82行,83行,84行各执行一次:

GNU: Char: i (105, #o151, #x69) point=4663 of 12455 (37%) column=5 Char: RET (13, #o15, #xd) point=4687 of 12455 (38%) column=1 Char: SPC (32, #o40, #x20) point=4690 of 12455 (38%) column=1

neo: Char: i (105, #o151, #x69) point=4663 of 12455 (37%) column=5 Char: RET (13, #o15, #xd) point=4687 of 12455 (38%) column=1 Char: SPC (32, #o40, #x20) point=4690 of 12455 (38%) column=1

neo出问题时是在RET那行,看起来数值和GNU一样,就是方块光标位置不对。

darkhandz avatar Nov 27 '26 07:11 darkhandz

@darkhandz @definepi 好兄弟,你有 ai agent 吗?如果方便的话欢迎用 ai 根据 neomacs 的 AGENT.md 里的步骤来帮忙提 issue: https://github.com/eval-exec/neomacs/blob/main/AGENTS.md#9-issues-and-bug-reports

这类问题如果能提供一个最小可复现脚本,就能大大提高问题定位和修复的效率。

eval-exec avatar Nov 27 '26 07:11 eval-exec

这条信息很有价值,把问题缩小到了一处形状。

三个位置的 point、column、字符和 GNU 完全一致,这说明布局算出来的值是对的,错的只是「画在哪里」—— 也就是我之前说的 draw 侧。更关键的是:出问题的那一行是空行(column=1 且 point 处字符是 RET)。

这正是最可疑的一种:现在的绘制从「光标槽位里那个 glyph」推出 y(baseline - ascent),而空行那一格没有 glyph, 一旦回退到下一个有 glyph 的行,光标就会画到下面一行。我们在这一批里已经把这处逻辑写进日志了(就是还没合入的那半个 提交),所以只要拿到一份带日志的 bundle 就能一锤定音。

因此:

  • 不用再抓 bundle,等这批合入、你重新编译后再抓一次即可,我会在这里贴 landing commit。
  • 我这边会让负责显示的同学把「空行」这个形状加进自动化对比行(空行在窗口中段、配 hl-line / 行号 / 高 mode line 各跑一遍),如果是我们自己的 bug,就能在没有你参与的情况下先复现出来。

谢谢,这三次 what-cursor-position 比一份 bundle 更有用。

neomacs-agent[bot] avatar Nov 27 '26 07:11 neomacs-agent[bot]

已合入 main:e505d3d845(fix(display): a GUI tab bar with no items takes no space, like GNU (#856))。

这批里和你的问题直接相关的有:

  • fc4ebce921 — 产生 neomacs::cursor_geometry 日志的那一半(渲染线程的 stage=draw、布局的 stage=layout)。现在 启动时带上 RUST_LOG=warn,neomacs::cursor_geometry=debug 就真的有记录了。
  • a99df4037f — 光标逐行对比的自动化行(X11 + Wayland,含空行/换行/高字形等形状)。
  • fce3ccbea2 — #858:point 落在半行时按 GNU 默认策略居中,而不是每次只滚一行。
  • e505d3d845 — #856:空 tab bar 不再占空间。

请拉最新 main 重新编译,然后:

RUST_LOG=warn,neomacs::cursor_geometry=debug \
NEOMACS_DEBUG_DISPLAY_DUMP=/tmp/neomacs-display-debug.json \
./target/release/neomacs

复现(光标偏移停在屏幕上),M-x neomacs-dump-display-state,上传 json。这次 cursor_geometry_log 里会有成对的 stage=layout / stage=draw;把 frame_snapshot.text 清掉也不影响我们读那两行。

如果方便,仍然想知道偏移出现后按一次 C-l 是否恢复(你说不能,我记下来了),以及偏移是不是总在空行上。

neomacs-agent[bot] avatar Nov 27 '26 07:11 neomacs-agent[bot]

@darkhandz @definepi 好兄弟,你有 ai agent 吗?如果方便的话欢迎用 ai 根据 neomacs 的 AGENT.md 里的步骤来帮忙提 issue: https://github.com/eval-exec/neomacs/blob/main/AGENTS.md#9-issues-and-bug-reports

这类问题如果能提供一个最小可复现脚本,就能大大提高问题定位和修复的效率。

好兄弟,我也想的,但有些问题我也找不到最小配置是什么,我是将neomacs当作我日常GNU emacs的替代来尝试使用的,我会用我常用的doom配置(改过),打开我日常工作用的工程,然后使用过程中遇到的明显和GNU行为不一致的地方就会反馈。 所以有时反馈的问题只能让你agent通过debug log来分析,我最多可以帮它做一些操作来让它获得更多细节,但我真的没有时间或技术去从零配置一个环境来进行测试,我已经尽可能先用标准doom配置来复现,能复现我就会强调用原版doom。

对了,有什么命令编译能快点的?只pull了几个commit执行一次cargo xtask fresh-build --release感觉要上10分钟,build neomacsclient和neomacsbin卡得比较久。

darkhandz avatar Nov 27 '26 07:11 darkhandz