Skip to content

Commit

Permalink
rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
curlpipe committed Sep 20, 2024
1 parent 046e222 commit ad37137
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
8 changes: 6 additions & 2 deletions kaolinite/src/document.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,9 @@ impl Document {
let boundaries = tab_boundaries_backward(&line, self.tab_width);
let width = if boundaries.contains(&self.char_ptr) {
// Push the character pointer up
self.char_ptr = self.char_ptr.saturating_sub(self.tab_width.saturating_sub(1));
self.char_ptr = self
.char_ptr
.saturating_sub(self.tab_width.saturating_sub(1));
// There are spaces that should be treated as tabs (so should traverse the tab width)
self.tab_width
} else {
Expand Down Expand Up @@ -813,7 +815,9 @@ impl Document {
// Account for double width characters
idx = idx.saturating_sub(self.dbl_map.count(loc, true).unwrap_or(0));
// Account for tab characters
idx = idx.saturating_sub(self.tab_map.count(loc, true).unwrap_or(0) * self.tab_width.saturating_sub(1));
idx = idx.saturating_sub(
self.tab_map.count(loc, true).unwrap_or(0) * self.tab_width.saturating_sub(1),
);
idx
}

Expand Down
4 changes: 3 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ pub fn get_stdin() -> Option<String> {
let input = io::stdin()
.lock()
.lines()
.fold("".to_string(), |acc, line| acc + &line.unwrap_or_else(|_| "".to_string()) + "\n");
.fold("".to_string(), |acc, line| {
acc + &line.unwrap_or_else(|_| "".to_string()) + "\n"
});

return Some(input);
}
Expand Down
21 changes: 16 additions & 5 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,9 @@ impl StatusLine {
// Find functions to call and substitute in
let mut searcher = Searcher::new(r"\{[A-Za-z_][A-Za-z0-9_]*\}");
while let Some(m) = searcher.lfind(&part) {
let name = m.text.chars()
let name = m
.text
.chars()
.skip(1)
.take(m.text.chars().count().saturating_sub(2))
.collect::<String>();
Expand Down Expand Up @@ -873,16 +875,22 @@ impl ConfigColor {
ConfigColor::Green => LuaValue::String(env.create_string("green").expect(msg)),
ConfigColor::DarkGreen => LuaValue::String(env.create_string("darkgreen").expect(msg)),
ConfigColor::Yellow => LuaValue::String(env.create_string("yellow").expect(msg)),
ConfigColor::DarkYellow => LuaValue::String(env.create_string("darkyellow").expect(msg)),
ConfigColor::DarkYellow => {
LuaValue::String(env.create_string("darkyellow").expect(msg))
}
ConfigColor::Blue => LuaValue::String(env.create_string("blue").expect(msg)),
ConfigColor::DarkBlue => LuaValue::String(env.create_string("darkblue").expect(msg)),
ConfigColor::Magenta => LuaValue::String(env.create_string("magenta").expect(msg)),
ConfigColor::DarkMagenta => LuaValue::String(env.create_string("darkmagenta").expect(msg)),
ConfigColor::DarkMagenta => {
LuaValue::String(env.create_string("darkmagenta").expect(msg))
}
ConfigColor::Cyan => LuaValue::String(env.create_string("cyan").expect(msg)),
ConfigColor::DarkCyan => LuaValue::String(env.create_string("darkcyan").expect(msg)),
ConfigColor::White => LuaValue::String(env.create_string("white").expect(msg)),
ConfigColor::Grey => LuaValue::String(env.create_string("grey").expect(msg)),
ConfigColor::Transparent => LuaValue::String(env.create_string("transparent").expect(msg)),
ConfigColor::Transparent => {
LuaValue::String(env.create_string("transparent").expect(msg))
}
}
}

Expand Down Expand Up @@ -1096,7 +1104,10 @@ impl LuaUserData for Editor {
fn add_methods<'lua, M: LuaUserDataMethods<'lua, Self>>(methods: &mut M) {
// Reload the configuration file
methods.add_method_mut("reload_config", |lua, editor, ()| {
if editor.load_config(editor.config_path.clone(), &lua).is_err() {
if editor
.load_config(editor.config_path.clone(), &lua)
.is_err()
{
editor.feedback = Feedback::Error("Failed to reload config".to_string());
}
Ok(())
Expand Down
6 changes: 4 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,10 @@ fn run(cli: CommandLineInterface) -> Result<()> {
lua.load(PLUGIN_BOOTSTRAP).exec()?;
if editor
.borrow_mut()
.load_config(cli.config_path, &lua).is_err() {
editor.borrow_mut().feedback =
.load_config(cli.config_path, &lua)
.is_err()
{
editor.borrow_mut().feedback =
Feedback::Error("Failed to load configuration file".to_string());
}

Expand Down

0 comments on commit ad37137

Please sign in to comment.