+ Ignoring empty lines
+ Only adding / on '/' input activation
This commit is contained in:
parent
a8d4ca9028
commit
939ee8c73f
@ -198,7 +198,8 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
InputMode::Normal => match input {
|
InputMode::Normal => match input {
|
||||||
Key::Char('i') | Key::Char('/') => {
|
Key::Char('i') | Key::Char('/') => {
|
||||||
app.input_mode = InputMode::Editing;
|
app.input_mode = InputMode::Editing;
|
||||||
app.input.push('/');
|
// only add the slash on slash command start
|
||||||
|
if Key::Char('/') == input { app.input.push('/'); }
|
||||||
events.disable_exit_key();
|
events.disable_exit_key();
|
||||||
}
|
}
|
||||||
Key::Char('q') => {
|
Key::Char('q') => {
|
||||||
@ -213,16 +214,22 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
},
|
},
|
||||||
InputMode::Editing => match input {
|
InputMode::Editing => match input {
|
||||||
Key::Char('\n') => {
|
Key::Char('\n') => {
|
||||||
let cmd = Command::from(app.input.drain(..).collect());
|
let raw: String = app.input.drain(..).collect();
|
||||||
app.messages.push(match cmd {
|
let trimmed = raw.trim();
|
||||||
// only for networked commands do we need to touch cache
|
|
||||||
Command::Channel(id) => app.cache.switch_channel(id).await,
|
// ensure that we don't bother with empty input
|
||||||
Command::Server(host) => app.cache.switch_server(&host).await,
|
if trimmed.len() != 0 {
|
||||||
Command::Message(msg) => app.cache.send_message(&msg).await,
|
let cmd = Command::from(trimmed);
|
||||||
Command::ListHost => app.cache.list_hosts(),
|
app.messages.push(match cmd {
|
||||||
Command::ListChannel => app.cache.list_channels(),
|
// only for networked commands do we need to touch cache
|
||||||
_ => cmd
|
Command::Channel(id) => app.cache.switch_channel(id).await,
|
||||||
});
|
Command::Server(host) => app.cache.switch_server(&host).await,
|
||||||
|
Command::Message(msg) => app.cache.send_message(&msg).await,
|
||||||
|
Command::ListHost => app.cache.list_hosts(),
|
||||||
|
Command::ListChannel => app.cache.list_channels(),
|
||||||
|
_ => cmd
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Key::Char(c) => {
|
Key::Char(c) => {
|
||||||
app.input.push(c);
|
app.input.push(c);
|
||||||
|
Loading…
Reference in New Issue
Block a user