mirror of
https://github.com/openai/codex.git
synced 2026-11-27 23:50:52 +00:00
Preserve local Markdown link labels in the TUI (#50695)
## Why Path-like link labels were collapsed into their destinations, discarding the author's label text and formatting. ## What changed Preserve nonblank local link labels alongside the formatted destination as `label (target)`, including in tables. Empty or whitespace-only labels show only the destination. Keep destination formatting and fall back to the original destination when a local file URL cannot be parsed. Render file citations without a label so they continue to display only the formatted destination. ## Testing Update rendering and transcript-copy tests and snapshots to cover preserved path labels, styled labels, empty labels, malformed file URLs, tables, and Markdown escaping. GitOrigin-RevId: 2810b70f1ecdc59d7f90fa1b254b1e9069c8fc29
This commit is contained in:
committed by
copyberry
parent
58ae3ba611
commit
3a69ec3ef8
@@ -133,11 +133,8 @@ fn inline_code_selection_copies_only_selected_content() {
|
||||
(r"before ``real\_literal\!`` after", r"real\_literal\!"),
|
||||
("before [`foo_bar!`](/repo/foo_bar!) after", "repo/foo_bar!"),
|
||||
("before [`foo_bar!`](/repo/foo_bar!) after", "bar!"),
|
||||
(
|
||||
"[foo_bar!](/foo_bar!)[baz_qux!](/baz_qux!)",
|
||||
"foo_bar!baz_qux!",
|
||||
),
|
||||
("`foo_bar!`[baz_qux!](/baz_qux!)", "foo_bar!baz_qux!"),
|
||||
("[](/foo_bar!)[](/baz_qux!)", "foo_bar!baz_qux!"),
|
||||
("`foo_bar!`[](/baz_qux!)", "foo_bar!baz_qux!"),
|
||||
("before **[file](/repo/foo_bar!)** after", "foo_bar!"),
|
||||
(
|
||||
"| File |\n|---|\n| [`foo_bar!`](/repo/foo_bar!) |",
|
||||
@@ -168,11 +165,11 @@ fn inline_code_selection_copies_only_selected_content() {
|
||||
#[test]
|
||||
fn mixed_file_targets_preserve_markdown_escaping() {
|
||||
for (source, expected) in [
|
||||
("before [+](/+) after", "before + after"),
|
||||
("before [1.)](</1.)>) after", "before 1.) after"),
|
||||
("before [+](/+) after", "before + (+) after"),
|
||||
("before [1.)](</1.)>) after", "before 1.) (1.)) after"),
|
||||
(
|
||||
"| File |\n|---|\n| [`foo_bar!`](/repo/foo_bar!) |",
|
||||
"| File |\n|---|\n| repo/foo\\_bar\\! |",
|
||||
"| File |\n|---|\n| `foo_bar!` (repo/foo\\_bar\\!) |",
|
||||
),
|
||||
] {
|
||||
let layout = markdown_layout(source, /*width*/ 80);
|
||||
|
||||
+2
-2
@@ -22,9 +22,9 @@ before [`foo_bar!`](/repo/foo_bar!) after
|
||||
Selected "repo/foo_bar!" → ("repo/foo_bar!", PlainText)
|
||||
before [`foo_bar!`](/repo/foo_bar!) after
|
||||
Selected "bar!" → ("bar!", PlainText)
|
||||
[foo_bar!](/foo_bar!)[baz_qux!](/baz_qux!)
|
||||
[](/foo_bar!)[](/baz_qux!)
|
||||
Selected "foo_bar!baz_qux!" → ("foo_bar!baz_qux!", PlainText)
|
||||
`foo_bar!`[baz_qux!](/baz_qux!)
|
||||
`foo_bar!`[](/baz_qux!)
|
||||
Selected "foo_bar!baz_qux!" → ("foo_bar!baz_qux!", PlainText)
|
||||
before **[file](/repo/foo_bar!)** after
|
||||
Selected "foo_bar!" → ("foo_bar!", PlainText)
|
||||
|
||||
Reference in New Issue
Block a user