mirror of
https://github.com/nushell/nushell
synced 2024-11-15 09:27:08 +00:00
Fix panic when exploring empty dictionary (#12860)
- fixes #12841 # Description Add boundary checks to ensure that the row and column chosen in RecordView are not over the length of the possible row and columns. If we are out of bounds, we default to Value::nothing. # Tests + Formatting Tests ran and formatting done
This commit is contained in:
parent
cd381b74e0
commit
2ed77aef1d
1 changed files with 6 additions and 2 deletions
|
@ -20,7 +20,7 @@ use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};
|
|||
use nu_color_config::{get_color_map, StyleComputer};
|
||||
use nu_protocol::{
|
||||
engine::{EngineState, Stack},
|
||||
Record, Value,
|
||||
Record, Span, Value,
|
||||
};
|
||||
use ratatui::{layout::Rect, widgets::Block};
|
||||
use std::{borrow::Cow, collections::HashMap};
|
||||
|
@ -180,7 +180,11 @@ impl<'a> RecordView<'a> {
|
|||
Orientation::Left => (column, row),
|
||||
};
|
||||
|
||||
layer.records[row][column].clone()
|
||||
if layer.records.len() > row && layer.records[row].len() > column {
|
||||
layer.records[row][column].clone()
|
||||
} else {
|
||||
Value::nothing(Span::unknown())
|
||||
}
|
||||
}
|
||||
|
||||
fn create_tablew(&'a self, cfg: ViewConfig<'a>) -> TableW<'a> {
|
||||
|
|
Loading…
Reference in a new issue