|
1 | | -use crate::app::App; |
| 1 | +use crate::app::{App, SearchScope}; |
2 | 2 | use crate::session::{Role, SessionSource}; |
3 | 3 | use crate::theme::Theme; |
4 | 4 | use ratatui::{ |
@@ -54,19 +54,24 @@ pub fn render(frame: &mut Frame, app: &mut App) { |
54 | 54 | ]) |
55 | 55 | .split(main_layout[2]); |
56 | 56 |
|
57 | | - // Two-pane layout: 40% results, 2 space padding, 60% preview |
58 | | - let content_layout = Layout::default() |
59 | | - .direction(Direction::Horizontal) |
60 | | - .constraints([ |
61 | | - Constraint::Percentage(40), |
62 | | - Constraint::Length(2), // Padding between panes |
63 | | - Constraint::Percentage(60), |
64 | | - ]) |
65 | | - .split(content_with_padding[1]); |
66 | | - |
67 | | - render_results_list(frame, app, content_layout[0]); |
68 | | - // content_layout[1] is the padding space - left empty |
69 | | - render_preview(frame, app, content_layout[2]); |
| 57 | + // When no results, use full width for the hint message |
| 58 | + if app.results.is_empty() { |
| 59 | + render_results_list(frame, app, content_with_padding[1]); |
| 60 | + } else { |
| 61 | + // Two-pane layout: 40% results, 2 space padding, 60% preview |
| 62 | + let content_layout = Layout::default() |
| 63 | + .direction(Direction::Horizontal) |
| 64 | + .constraints([ |
| 65 | + Constraint::Percentage(40), |
| 66 | + Constraint::Length(2), // Padding between panes |
| 67 | + Constraint::Percentage(60), |
| 68 | + ]) |
| 69 | + .split(content_with_padding[1]); |
| 70 | + |
| 71 | + render_results_list(frame, app, content_layout[0]); |
| 72 | + // content_layout[1] is the padding space - left empty |
| 73 | + render_preview(frame, app, content_layout[2]); |
| 74 | + } |
70 | 75 |
|
71 | 76 | // Add horizontal padding to status bar |
72 | 77 | let status_with_padding = Layout::default() |
@@ -152,10 +157,20 @@ fn render_results_list(frame: &mut Frame, app: &mut App, area: Rect) { |
152 | 157 | let available_width = area.width.saturating_sub(2) as usize; |
153 | 158 |
|
154 | 159 | if app.results.is_empty() { |
155 | | - if !app.query.is_empty() { |
| 160 | + // Show hint to search everywhere if scoped and no results |
| 161 | + let is_scoped = !matches!(app.search_scope, SearchScope::Everything); |
| 162 | + if is_scoped { |
| 163 | + let prefix = if app.query.is_empty() { "Nothing here." } else { "No results." }; |
| 164 | + let hint = Line::from(vec![ |
| 165 | + Span::styled(format!(" {} Press ", prefix), Style::default().fg(t.snippet_fg)), |
| 166 | + Span::styled(" / ", Style::default().bg(t.keycap_bg)), |
| 167 | + Span::styled(" to search everywhere.", Style::default().fg(t.snippet_fg)), |
| 168 | + ]); |
| 169 | + frame.render_widget(Paragraph::new(hint), area); |
| 170 | + } else if !app.query.is_empty() { |
156 | 171 | let paragraph = Paragraph::new(Span::styled( |
157 | | - "No results", |
158 | | - Style::default().fg(t.dim_fg), |
| 172 | + " No results.", |
| 173 | + Style::default().fg(t.snippet_fg), |
159 | 174 | )); |
160 | 175 | frame.render_widget(paragraph, area); |
161 | 176 | } |
|
0 commit comments