mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
Add search, selection, and link navigation to document previews (#61889)
## What changed - Enable search, keyboard and mouse selection, and Markdown copying in sidebar document previews, including copying while offline. - Navigate links with `Tab` and `Shift+Tab`, then open them with `Enter`. Open web links in the browser and resolve file links relative to the current document. - Render local Markdown links as interactive labels and preserve distinct link occurrences across wrapping. - Add document zoom, scroll indicators, and contextual footer hints. Disambiguate document tabs with matching filenames, including when titles are truncated. - Cancel pending PRIMARY selection publication when a document is hidden and preserve the intended destination for composer clipboard pastes. ## Testing Extend document preview coverage for search, selection, offline copying, link activation, hidden PRIMARY selections, and duplicate tab titles. Add rendering tests for local link labels and navigation across wrapped links. GitOrigin-RevId: 80240fa580eed9dda971759afc49bc2bb909fcb5
This commit is contained in:
@@ -99,6 +99,7 @@ pub(crate) struct TranscriptView {
|
||||
pub(crate) primary_selection: bool,
|
||||
position: Position,
|
||||
follow_control: follow_control::FollowControl,
|
||||
pub(crate) show_follow_control: bool,
|
||||
copy_feedback: Option<composer_gap::CopyFeedback>,
|
||||
composer_tip: Option<(Rect, HyperlinkLine)>,
|
||||
turn_tip_key: Option<EntryKey>,
|
||||
@@ -141,6 +142,7 @@ impl Default for TranscriptView {
|
||||
primary_selection: false,
|
||||
position: Position::Latest,
|
||||
follow_control: follow_control::FollowControl::default(),
|
||||
show_follow_control: true,
|
||||
copy_feedback: None,
|
||||
composer_tip: None,
|
||||
turn_tip_key: None,
|
||||
@@ -343,6 +345,28 @@ impl TranscriptView {
|
||||
self.render_search(buf);
|
||||
}
|
||||
|
||||
pub(crate) fn paint_document_scroll_indicators(
|
||||
&mut self,
|
||||
area: Rect,
|
||||
buf: &mut Buffer,
|
||||
cells: &[Arc<dyn HistoryCell>],
|
||||
) {
|
||||
if area.height < 2 || area.width < 3 {
|
||||
return;
|
||||
}
|
||||
let start = self.start(cells);
|
||||
for (visible, row, arrow) in [
|
||||
(start > (0, 0), area.top(), "↑"),
|
||||
(start < self.bottom_start(cells), area.bottom() - 1, "↓"),
|
||||
] {
|
||||
if visible {
|
||||
buf[(area.right() - 1, row)]
|
||||
.set_symbol(arrow)
|
||||
.set_style(crate::style::secondary_text_style());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Persist the clamped reading position after the last paint at the final viewport height.
|
||||
pub(crate) fn finish_collapse_layout(&mut self, cells: &[Arc<dyn HistoryCell>]) {
|
||||
if self.area.is_empty()
|
||||
@@ -570,6 +594,15 @@ impl TranscriptView {
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn jump_to_offset(&mut self, cells: &[Arc<dyn HistoryCell>], offset: usize) {
|
||||
self.position = Position::Reading(Anchor {
|
||||
key: self.entry_key(cells, /*index*/ 0),
|
||||
index: 0,
|
||||
offset,
|
||||
row_bias: 0,
|
||||
});
|
||||
}
|
||||
|
||||
pub(crate) fn jump_to_latest(&mut self) {
|
||||
self.disclosure.resume_after_approval = None;
|
||||
self.cancel_search();
|
||||
|
||||
Reference in New Issue
Block a user