mirror of
https://github.com/openai/codex.git
synced 2026-11-23 23:10:47 +00:00
## What changed - Extend sidebar previews beyond Markdown to source files, including extensionless files. Preserve line and column targets such as `./Makefile#L12C3`, scroll to the target, and highlight its line and character. - Render source previews with syntax highlighting and line numbers when space permits. Keep plain Markdown links rendered as Markdown, and show source when a location is specified. - Show local link labels without appended destinations when workspace previews are available, and emphasize links on hover. Refresh rendering when preview availability changes. - Limit source previews to 1 MiB and 10,000 lines, and disable document previews for Windows workspaces. ## Testing Add coverage for extensionless link parsing, matching hover and click targets, streamed file citation metadata, and source navigation with CRLF input, tab reuse, and Escape handling. GitOrigin-RevId: c2629b122628a4f5afa17df1890f63bd1c9bbcf6
41 lines
1.1 KiB
Rust
41 lines
1.1 KiB
Rust
//! Tests for local-link parsing and root-preserving separator normalization.
|
|
|
|
use super::FileLink;
|
|
use super::SourceLocation;
|
|
use super::sidebar_file_link;
|
|
use super::trim_trailing_local_path_separator;
|
|
use pretty_assertions::assert_eq;
|
|
|
|
#[test]
|
|
fn trailing_separator_trimming_preserves_local_roots() {
|
|
let paths = ["/", "//", "C:/", "dir/", "//server/share/", "C:/dir/"];
|
|
assert_eq!(
|
|
paths.map(trim_trailing_local_path_separator),
|
|
["/", "//", "C:/", "dir", "//server/share", "C:/dir"]
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn sidebar_keeps_line_and_column_for_extensionless_source_links() {
|
|
assert_eq!(
|
|
sidebar_file_link("./Makefile#L12C3"),
|
|
Some(FileLink {
|
|
path: "./Makefile".into(),
|
|
location: Some(SourceLocation {
|
|
line: 12,
|
|
column: 3
|
|
}),
|
|
}),
|
|
);
|
|
for path in ["Makefile", "build/Makefile"] {
|
|
assert_eq!(
|
|
sidebar_file_link(path),
|
|
Some(FileLink {
|
|
path: path.into(),
|
|
location: None,
|
|
}),
|
|
);
|
|
}
|
|
assert_eq!(sidebar_file_link("https://example.org/Makefile#L12"), None);
|
|
}
|