fix: full title in preview pane
1 file changed, +21 -21
+21-21src/views/browser.rs
| @@ -417,7 +417,14 @@ impl BrowserView { | ||
| 417 | 417 | PathSegment::Index(i) => format!("[{}]", i), |
| 418 | 418 | } |
| 419 | 419 | }; |
| 420 | - let selected_label = current_entries.get(self.selection).map(|e| e.label.as_str()).unwrap_or(""); | |
| 420 | + let selected_label = if in_focus_root { | |
| 421 | + // Use full path for the right pane title in focus mode | |
| 422 | + self.focused.get(self.selection) | |
| 423 | + .map(|fp| focus_path_full(fp)) | |
| 424 | + .unwrap_or_default() | |
| 425 | + } else { | |
| 426 | + current_entries.get(self.selection).map(|e| e.label.clone()).unwrap_or_default() | |
| 427 | + }; | |
| 421 | 428 | let focus_suffix = if self.focus_mode && !self.focused.is_empty() { |
| 422 | 429 | format!(" ({} focused)", self.focused.len()) |
| 423 | 430 | } else { |
| @@ -1229,13 +1236,13 @@ fn focus_path_full(fp: &[PathSegment]) -> String { | ||
| 1229 | 1236 | }).collect::<Vec<_>>().join(".") |
| 1230 | 1237 | } |
| 1231 | 1238 | |
| 1232 | -/// Short label for a focused path: "filename...lastKey[idx]" | |
| 1239 | +const FOCUS_LABEL_MAX: usize = 40; | |
| 1240 | + | |
| 1241 | +/// Short label for a focused path: "first_word...last_chars" if over max, else full. | |
| 1233 | 1242 | fn focus_path_label(fp: &[PathSegment]) -> String { |
| 1234 | - if fp.is_empty() { | |
| 1235 | - return String::new(); | |
| 1236 | - } | |
| 1237 | - if fp.len() <= 2 { | |
| 1238 | - return focus_path_full(fp); | |
| 1243 | + let full = focus_path_full(fp); | |
| 1244 | + if full.len() <= FOCUS_LABEL_MAX { | |
| 1245 | + return full; | |
| 1239 | 1246 | } |
| 1240 | 1247 | |
| 1241 | 1248 | let first = match &fp[0] { |
| @@ -1243,21 +1250,14 @@ fn focus_path_label(fp: &[PathSegment]) -> String { | ||
| 1243 | 1250 | PathSegment::Index(i) => format!("[{}]", i), |
| 1244 | 1251 | }; |
| 1245 | 1252 | |
| 1246 | - // Build the tail: last key + any trailing indices | |
| 1247 | - let mut tail_parts = Vec::new(); | |
| 1248 | - for seg in fp.iter().rev() { | |
| 1249 | - match seg { | |
| 1250 | - PathSegment::Index(i) => tail_parts.push(format!("[{}]", i)), | |
| 1251 | - PathSegment::Key(k) => { | |
| 1252 | - tail_parts.push(k.clone()); | |
| 1253 | - break; | |
| 1254 | - } | |
| 1255 | - } | |
| 1253 | + // "first...tail" where tail fills remaining chars | |
| 1254 | + let ellipsis = "..."; | |
| 1255 | + let budget = FOCUS_LABEL_MAX.saturating_sub(first.len() + ellipsis.len()); | |
| 1256 | + if budget == 0 { | |
| 1257 | + return format!("{}{}", first, ellipsis); | |
| 1256 | 1258 | } |
| 1257 | - tail_parts.reverse(); | |
| 1258 | - let tail = tail_parts.join("."); | |
| 1259 | - | |
| 1260 | - format!("{}...{}", first, tail) | |
| 1259 | + let tail = &full[full.len().saturating_sub(budget)..]; | |
| 1260 | + format!("{}{}{}", first, ellipsis, tail) | |
| 1261 | 1261 | } |
| 1262 | 1262 | |
| 1263 | 1263 | /// Convert an entry label to the correct PathSegment. |