Skip to content

Commit

Permalink
Handle out of bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
dantleech committed Nov 10, 2024
1 parent a462511 commit ab866ab
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/component/activity_list/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use tui::{
layout::{Constraint, Layout},
prelude::Buffer,
style::Style,
widgets::{Block, Borders, Clear, Paragraph, StatefulWidget, Table, TableState, Widget},
widgets::{Block, Borders, Clear, Paragraph, StatefulWidget, Table, TableState, Widget, block::Title},
};
use tui_input::backend::crossterm::EventHandler;
use tui_input::Input;
Expand Down Expand Up @@ -151,7 +151,8 @@ impl View for ActivityList {
let p = Paragraph::new(app.activity_list.filter_text_area.value()).block(
Block::default()
.borders(Borders::ALL)
.title("Filter")
.title(Title::from("Filter"))
.title(Title::from("e.g. type=\"Run\" and distance > 21000 and title ~ 'Marathon'").position(tui::widgets::block::Position::Bottom))
.border_style(Style::default().fg(ColorTheme::Dialog.to_color())),
);

Expand Down
8 changes: 8 additions & 0 deletions src/expr/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ impl Lexer<'_> {
length += 1;
}

if self.peek(length) == '\0' {
let val = self.spawn_advance(TokenKind::Unkown, length);
return val;
}

let val = self.spawn_advance(TokenKind::String, length);
self.advance();
val
Expand Down Expand Up @@ -242,6 +247,9 @@ mod test {
let mut l = Lexer::new("'or'");
let t = l.next();
assert_eq!("or", l.token_value(&t));

// unterminated string
assert_eq!(TokenKind::Unkown, Lexer::new("' ").next().kind);
}

#[test]
Expand Down

0 comments on commit ab866ab

Please sign in to comment.