mirror of
https://github.com/openai/codex.git
synced 2026-11-16 22:00:36 +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:
@@ -121,6 +121,72 @@ impl TranscriptView {
|
||||
.link_at(visible.row, column - self.area.x, self.document_links)
|
||||
}
|
||||
|
||||
pub(crate) fn cycle_document_link(
|
||||
&mut self,
|
||||
cells: &[Arc<dyn HistoryCell>],
|
||||
selected: Option<usize>,
|
||||
forward: bool,
|
||||
) -> Option<usize> {
|
||||
let layout = self.layout(cells, /*index*/ 0)?;
|
||||
let links = layout.document_links();
|
||||
let count = links.len();
|
||||
if count == 0 {
|
||||
return None;
|
||||
}
|
||||
let index = match selected {
|
||||
Some(index) if forward => (index + 1) % count,
|
||||
Some(index) => (index + count - 1) % count,
|
||||
None if forward => 0,
|
||||
None => count - 1,
|
||||
};
|
||||
let offset = links[index].0.start;
|
||||
let row = layout.row_for_offset(offset);
|
||||
if !self
|
||||
.visible
|
||||
.iter()
|
||||
.any(|visible| visible.index == 0 && visible.row == row)
|
||||
{
|
||||
self.jump_to_offset(cells, offset);
|
||||
}
|
||||
Some(index)
|
||||
}
|
||||
|
||||
pub(crate) fn document_link(
|
||||
&mut self,
|
||||
cells: &[Arc<dyn HistoryCell>],
|
||||
index: usize,
|
||||
) -> Option<String> {
|
||||
self.layout(cells, /*index*/ 0)?
|
||||
.document_links()
|
||||
.into_iter()
|
||||
.nth(index)
|
||||
.map(|(_, link)| link)
|
||||
}
|
||||
|
||||
pub(crate) fn paint_document_link(
|
||||
&mut self,
|
||||
cells: &[Arc<dyn HistoryCell>],
|
||||
index: usize,
|
||||
buf: &mut ratatui::buffer::Buffer,
|
||||
) {
|
||||
let Some(layout) = self.layout(cells, /*index*/ 0) else {
|
||||
return;
|
||||
};
|
||||
let Some((range, _)) = layout.document_links().into_iter().nth(index) else {
|
||||
return;
|
||||
};
|
||||
for (row, visible) in self.visible.iter().enumerate() {
|
||||
if visible.index == 0 {
|
||||
visible.layout.highlight(
|
||||
range.clone(),
|
||||
Rect::new(self.area.x, self.area.y + row as u16, self.area.width, 1),
|
||||
buf,
|
||||
visible.row,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn navigate_pager(
|
||||
&mut self,
|
||||
key: KeyEvent,
|
||||
|
||||
Reference in New Issue
Block a user