Skip to content

Commit

Permalink
Rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
gwenn committed May 16, 2020
1 parent c71b4cf commit a74c65a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/input_validation.rs
Expand Up @@ -8,7 +8,7 @@ struct InputValidator {}

impl Validator for InputValidator {
fn validate(&self, ctx: &mut ValidationContext) -> Result<ValidationResult, ReadlineError> {
use ValidationResult::{Incomplete,Invalid, Valid};
use ValidationResult::{Incomplete, Invalid, Valid};
let input = ctx.input();
let result = if !input.starts_with("SELECT") {
Invalid(Some(" --< Expect: SELECT stmt".to_owned()))
Expand Down
9 changes: 9 additions & 0 deletions rustfmt.toml
Expand Up @@ -2,3 +2,12 @@ wrap_comments = true
format_strings = true
error_on_unformatted = false
reorder_impl_items = true

condense_wildcard_suffixes = true
format_code_in_doc_comments = true
format_macro_matchers = true
format_macro_bodies = true
#merge_imports = true
normalize_doc_attributes = true
use_field_init_shorthand = true
use_try_shorthand = true
2 changes: 1 addition & 1 deletion src/edit.rs
Expand Up @@ -89,7 +89,7 @@ impl<'out, 'prompt, H: Helper> State<'out, 'prompt, H> {
self.refresh_line()?;
continue;
}
if let Ok(Cmd::Replace(_, _)) = rc {
if let Ok(Cmd::Replace(..)) = rc {
self.changes.borrow_mut().begin();
}
return rc;
Expand Down
18 changes: 9 additions & 9 deletions src/keymap.rs
Expand Up @@ -106,24 +106,24 @@ impl Cmd {
Cmd::Kill(Movement::BackwardChar(_)) | Cmd::Kill(Movement::ForwardChar(_)) => true,
Cmd::ClearScreen
| Cmd::Kill(_)
| Cmd::Replace(_, _)
| Cmd::Replace(..)
| Cmd::Noop
| Cmd::Suspend
| Cmd::Yank(_, _)
| Cmd::Yank(..)
| Cmd::YankPop => false,
_ => true,
}
}

fn is_repeatable_change(&self) -> bool {
match *self {
Cmd::Insert(_, _)
Cmd::Insert(..)
| Cmd::Kill(_)
| Cmd::ReplaceChar(_, _)
| Cmd::Replace(_, _)
| Cmd::SelfInsert(_, _)
| Cmd::ReplaceChar(..)
| Cmd::Replace(..)
| Cmd::SelfInsert(..)
| Cmd::ViYankTo(_)
| Cmd::Yank(_, _) => true,
| Cmd::Yank(..) => true,
// Cmd::TransposeChars | TODO Validate
_ => false,
}
Expand Down Expand Up @@ -765,9 +765,9 @@ impl InputState {
};
debug!(target: "rustyline", "Vi insert: {:?}", cmd);
if cmd.is_repeatable_change() {
if let (Cmd::Replace(_, _), Cmd::SelfInsert(_, _)) = (&self.last_cmd, &cmd) {
if let (Cmd::Replace(..), Cmd::SelfInsert(..)) = (&self.last_cmd, &cmd) {
// replacing...
} else if let (Cmd::SelfInsert(_, _), Cmd::SelfInsert(_, _)) = (&self.last_cmd, &cmd) {
} else if let (Cmd::SelfInsert(..), Cmd::SelfInsert(..)) = (&self.last_cmd, &cmd) {
// inserting...
} else {
self.last_cmd = cmd.clone();
Expand Down

0 comments on commit a74c65a

Please sign in to comment.