mirror of
https://github.com/zaphar/sheetsui.git
synced 2025-07-25 06:19:51 -04:00
Compare commits
2 Commits
f8faeacf39
...
c758f65a5c
Author | SHA1 | Date | |
---|---|---|---|
c758f65a5c | |||
142ecef24c |
@ -5,7 +5,7 @@ use slice_utils::{Measured, Peekable, Seekable, Span, StrCursor};
|
|||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum Cmd<'a> {
|
pub enum Cmd<'a> {
|
||||||
Write(Option<&'a str>),
|
Write(Option<&'a str>),
|
||||||
InsertRow(usize),
|
InsertRows(usize),
|
||||||
InsertColumns(usize),
|
InsertColumns(usize),
|
||||||
RenameSheet(Option<usize>, &'a str),
|
RenameSheet(Option<usize>, &'a str),
|
||||||
NewSheet(Option<&'a str>),
|
NewSheet(Option<&'a str>),
|
||||||
@ -155,7 +155,7 @@ fn try_consume_insert_row<'cmd, 'i: 'cmd>(
|
|||||||
return Err("Invalid command: Did you mean to type `insert-rows <arg>`?");
|
return Err("Invalid command: Did you mean to type `insert-rows <arg>`?");
|
||||||
}
|
}
|
||||||
let arg = input.span(0..).trim();
|
let arg = input.span(0..).trim();
|
||||||
return Ok(Some(Cmd::InsertRow(if arg.is_empty() {
|
return Ok(Some(Cmd::InsertRows(if arg.is_empty() {
|
||||||
1
|
1
|
||||||
} else {
|
} else {
|
||||||
if let Ok(count) = arg.parse() {
|
if let Ok(count) = arg.parse() {
|
||||||
|
@ -425,7 +425,7 @@ impl<'ws> Workspace<'ws> {
|
|||||||
self.book.evaluate();
|
self.book.evaluate();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
Ok(Some(Cmd::InsertRow(count))) => {
|
Ok(Some(Cmd::InsertRows(count))) => {
|
||||||
self.book.insert_rows(self.book.location.row, count)?;
|
self.book.insert_rows(self.book.location.row, count)?;
|
||||||
self.book.evaluate();
|
self.book.evaluate();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
@ -657,6 +657,11 @@ impl<'ws> Workspace<'ws> {
|
|||||||
KeyCode::Char('s') if key.modifiers == KeyModifiers::CONTROL => {
|
KeyCode::Char('s') if key.modifiers == KeyModifiers::CONTROL => {
|
||||||
self.save_file()?;
|
self.save_file()?;
|
||||||
}
|
}
|
||||||
|
KeyCode::Char('s') if key.modifiers != KeyModifiers::CONTROL => {
|
||||||
|
self.book.clear_current_cell()?;
|
||||||
|
self.text_area = reset_text_area(String::new());
|
||||||
|
self.enter_edit_mode();
|
||||||
|
}
|
||||||
KeyCode::Char('r') if key.modifiers == KeyModifiers::CONTROL => {
|
KeyCode::Char('r') if key.modifiers == KeyModifiers::CONTROL => {
|
||||||
self.enter_range_select_mode();
|
self.enter_range_select_mode();
|
||||||
}
|
}
|
||||||
|
@ -35,7 +35,7 @@ fn test_insert_rows_cmd() {
|
|||||||
let output = result.unwrap();
|
let output = result.unwrap();
|
||||||
assert!(output.is_some());
|
assert!(output.is_some());
|
||||||
let cmd = output.unwrap();
|
let cmd = output.unwrap();
|
||||||
assert_eq!(cmd, Cmd::InsertRow(1));
|
assert_eq!(cmd, Cmd::InsertRows(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -46,7 +46,7 @@ fn test_insert_rows_cmd_short() {
|
|||||||
let output = result.unwrap();
|
let output = result.unwrap();
|
||||||
assert!(output.is_some());
|
assert!(output.is_some());
|
||||||
let cmd = output.unwrap();
|
let cmd = output.unwrap();
|
||||||
assert_eq!(cmd, Cmd::InsertRow(1));
|
assert_eq!(cmd, Cmd::InsertRows(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user