feat(tui): enable JSON expansion during Loading state

This commit is contained in:
dailz
2026-04-14 16:52:17 +08:00
parent 4ec3eb7cee
commit 0941092b07

View File

@@ -212,9 +212,6 @@ impl App {
/// Compute visual height for a single line without storing it.
fn compute_visual_height(&self, line: usize, width: usize) -> usize {
if self.is_loading() {
return 1; // sampling mode: 1 visual row per line
}
let raw = self.get_line(line).unwrap_or_default();
let display_text = if self.json_format {
format_json_line(&raw)
@@ -508,15 +505,13 @@ impl App {
self.last_g_press = None;
}
KeyCode::Tab => {
if !self.is_loading() {
self.json_format = !self.json_format;
self.viewport_cache.invalidate();
let width = self.viewport_cache.width;
if let AppLoadingState::Ready { reader } = &mut self.loading_state {
reader.invalidate_visual_height_index();
if width > 0 {
reader.start_visual_height_rebuild(width, self.json_format);
}
self.json_format = !self.json_format;
self.viewport_cache.invalidate();
let width = self.viewport_cache.width;
if let AppLoadingState::Ready { reader } = &mut self.loading_state {
reader.invalidate_visual_height_index();
if width > 0 {
reader.start_visual_height_rebuild(width, self.json_format);
}
}
self.last_g_press = None;