cargo clippy
This commit is contained in:
@@ -338,7 +338,10 @@ pub fn parse(input: &str) -> Option<Command> {
|
|||||||
Some(Command::Repeat(mode))
|
Some(Command::Repeat(mode))
|
||||||
}
|
}
|
||||||
"seek" => args.get(0).and_then(|arg| match arg.chars().next() {
|
"seek" => args.get(0).and_then(|arg| match arg.chars().next() {
|
||||||
Some(x) if x == '-' || x == '+' => String::from_iter(arg.chars().skip(1))
|
Some(x) if x == '-' || x == '+' => arg
|
||||||
|
.chars()
|
||||||
|
.skip(1)
|
||||||
|
.collect::<String>()
|
||||||
.parse::<i32>()
|
.parse::<i32>()
|
||||||
.ok()
|
.ok()
|
||||||
.map(|amount| {
|
.map(|amount| {
|
||||||
@@ -350,7 +353,9 @@ pub fn parse(input: &str) -> Option<Command> {
|
|||||||
},
|
},
|
||||||
))
|
))
|
||||||
}),
|
}),
|
||||||
_ => String::from_iter(arg.chars())
|
_ => arg
|
||||||
|
.chars()
|
||||||
|
.collect::<String>()
|
||||||
.parse()
|
.parse()
|
||||||
.ok()
|
.ok()
|
||||||
.map(|amount| Command::Seek(SeekDirection::Absolute(amount))),
|
.map(|amount| Command::Seek(SeekDirection::Absolute(amount))),
|
||||||
|
|||||||
@@ -257,22 +257,21 @@ async fn main() {
|
|||||||
let mut main = s.find_name::<ui::layout::Layout>("main").unwrap();
|
let mut main = s.find_name::<ui::layout::Layout>("main").unwrap();
|
||||||
main.clear_cmdline();
|
main.clear_cmdline();
|
||||||
}
|
}
|
||||||
|
let cmd_without_prefix = &cmd[1..];
|
||||||
if cmd.strip_prefix('/').is_some() {
|
if cmd.strip_prefix('/').is_some() {
|
||||||
let query = &cmd[1..];
|
let command = Command::Jump(JumpMode::Query(cmd_without_prefix.to_string()));
|
||||||
let command = Command::Jump(JumpMode::Query(query.to_string()));
|
|
||||||
if let Some(data) = s.user_data::<UserData>().cloned() {
|
if let Some(data) = s.user_data::<UserData>().cloned() {
|
||||||
data.cmd.handle(s, command);
|
data.cmd.handle(s, command);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let c = &cmd[1..];
|
let parsed = command::parse(cmd_without_prefix);
|
||||||
let parsed = command::parse(c);
|
|
||||||
if let Some(parsed) = parsed {
|
if let Some(parsed) = parsed {
|
||||||
if let Some(data) = s.user_data::<UserData>().cloned() {
|
if let Some(data) = s.user_data::<UserData>().cloned() {
|
||||||
data.cmd.handle(s, parsed)
|
data.cmd.handle(s, parsed)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let mut main = s.find_name::<ui::layout::Layout>("main").unwrap();
|
let mut main = s.find_name::<ui::layout::Layout>("main").unwrap();
|
||||||
let err_msg = format!("Unknown command: \"{}\"", c);
|
let err_msg = format!("Unknown command: \"{}\"", cmd_without_prefix);
|
||||||
main.set_result(Err(err_msg));
|
main.set_result(Err(err_msg));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user