fix(terminal_view): 修复 SSH 连接窗口空行的时间戳占位括号与行号 - #259
Merged
Merged
Conversation
左边距为每一屏幕行生成时间戳文本,尚未有输出的行(光标下方的空行) 此前会画出 `[ ]` 占位括号,整屏空行看起来全是括号和空白。 改为没有时间戳时不画占位符:只显示行号时补足时间戳列宽的空白以保证 行号对齐,时间戳与行号都不显示时该行留空,由元素侧跳过绘制。列宽与 行号对齐行为不变。 Refs #244
左边距改为以“该行是否已有输出”为唯一判定:时间线里没有这一行的时间戳, 说明它还没有任何输出(光标下方的空行),此时整行留空——既不画时间戳 占位括号,也不显示行号。 原来只有显示时间戳时才查时间线,行号列会无条件铺满整屏,空行上挂着 一串孤立的行号。现在两列共用同一个判定。 行时间轴新增一次加锁的按行批量查询 `labels`,视图整帧只加锁一次、不做 逐行查询;原先仅服务视图逐行查询的单行 `label` 已无生产调用方,一并移除, 只保留批量这一条查找路径。 Refs #244
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #244
Description
The per-line margin (timestamps + line numbers, introduced for #220) drew a full-width row for every on-screen line, so lines that had not produced any output yet still got a
[ ]timestamp placeholder — and later, an orphan line number under the cursor. In a fresh SSH session that littered the whole window below the cursor.This PR makes “has this line produced output yet?” the single criterion for the entire margin: a margin row is only rendered for lines that already have a timestamp in the line timeline. Rows without a label become an empty string, and the element already skips empty rows — so neither the placeholder brackets nor the line number is painted.
crates/terminal/src/line_timeline.rs: addSharedLineTimeline::labels(first_id, count)— one lock for the whole screen, O(log n + count), and one consistent per-frame snapshot. The single-rowlabel()had no production caller left after the switch, so it was removed rather than kept as a parallel path.crates/terminal_view/src/view/terminal_render.rs:line_margin_row_textreturns an empty string when the label isNone;build_line_marginnow consults the timeline regardless of the timestamp toggle (it previously only queried it when timestamps were enabled, so number-only mode could not detect blank lines at all).The margin column width is unchanged, so lines that do have output keep exactly the same alignment as before.
Screenshot
[ ]on every empty line)How to Test
Automated:
The behavioural test is
margin_blanks_rows_below_the_last_output: it drives a realTerm(writes"$ one\r\ntwo\r\n"), then asserts every row below the last output is empty — for the timestamp mode and for the number-only mode. Mutation check: restoring a “render an empty label anyway” path turns that test red (["[] 4 ", "[] 5 ", "[] 6 "]), so the test pins the wiring and not just the pure helper.Manual (not done by me — please confirm visually):
[HH:MM:SS]and/or the line number, aligned exactly as before.Checklist
cargo runfor story tests related to the changes.