Some minor code cleanups and fixes.

This commit is contained in:
Nathan Vegdahl 2020-01-25 04:28:00 +09:00
parent f3c59558bb
commit e6a7d26dbd

View File

@ -82,7 +82,9 @@ macro_rules! ui_loop {
// Draw the editor to screen // Draw the editor to screen
if should_redraw { if should_redraw {
// Make sure display dimensions are up-to-date. // Make sure display dimensions are up-to-date.
$term_ui.editor.update_dim($term_ui.height, $term_ui.width); $term_ui
.editor
.update_dim($term_ui.height - 1, $term_ui.width);
$term_ui $term_ui
.editor .editor
.formatter .formatter
@ -159,7 +161,6 @@ impl TermUI {
match key { match key {
KeyEvent { KeyEvent {
code: KeyCode::Char('q'), code: KeyCode::Char('q'),
// modifiers: EMPTY_MOD,
modifiers: KeyModifiers::CONTROL, modifiers: KeyModifiers::CONTROL,
} => { } => {
self.quit = true; self.quit = true;
@ -364,13 +365,8 @@ impl TermUI {
// Jump to line! // Jump to line!
if !cancel { if !cancel {
if let Ok(n) = line.parse() { if let Ok(n) = line.parse::<usize>() {
let n2: usize = n; // Weird work-around: the type of n wasn't being inferred self.editor.jump_to_line(n - 1.min(n));
if n2 > 0 {
self.editor.jump_to_line(n2 - 1);
} else {
self.editor.jump_to_line(0);
}
} }
} }
} }