Skip to content

Commit

Permalink
chore: rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-arnold committed May 25, 2024
1 parent e9e3d62 commit 7b125ba
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 84 deletions.
11 changes: 7 additions & 4 deletions alacritty/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ fn main() {
let dest = env::var("OUT_DIR").unwrap();
let mut file = File::create(Path::new(&dest).join("gl_bindings.rs")).unwrap();

Registry::new(Api::Gl, (3, 3), Profile::Core, Fallbacks::All, [
"GL_ARB_blend_func_extended",
"GL_KHR_debug",
])
Registry::new(
Api::Gl,
(3, 3),
Profile::Core,
Fallbacks::All,
["GL_ARB_blend_func_extended", "GL_KHR_debug"],
)
.write_bindings(GlobalGenerator, &mut file)
.unwrap();

Expand Down
10 changes: 4 additions & 6 deletions alacritty/src/display/damage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,12 +345,10 @@ mod tests {
let width = 10;
let size_info = SizeInfo::new(viewport_height, viewport_height, 5., 5., 0., 0., true);
frame_damage.add_viewport_rect(&size_info, x, y, width, height);
assert_eq!(frame_damage.rects[0], Rect {
x,
y: viewport_height as i32 - y - height,
width,
height
});
assert_eq!(
frame_damage.rects[0],
Rect { x, y: viewport_height as i32 - y - height, width, height }
);
assert_eq!(frame_damage.rects[0].y, viewport_y_to_damage_y(&size_info, y, height));
assert_eq!(damage_y_to_viewport_y(&size_info, &frame_damage.rects[0]), y);
}
Expand Down
26 changes: 12 additions & 14 deletions alacritty/src/message_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -264,10 +264,10 @@ mod tests {

let lines = message_buffer.message().unwrap().text(&size);

assert_eq!(lines, vec![
String::from("hahahahahahahahaha [X]"),
String::from("[MESSAGE TRUNCATED] ")
]);
assert_eq!(
lines,
vec![String::from("hahahahahahahahaha [X]"), String::from("[MESSAGE TRUNCATED] ")]
);
}

#[test]
Expand Down Expand Up @@ -353,11 +353,10 @@ mod tests {

let lines = message_buffer.message().unwrap().text(&size);

assert_eq!(lines, vec![
String::from("a [X]"),
String::from("bc "),
String::from("defg ")
]);
assert_eq!(
lines,
vec![String::from("a [X]"), String::from("bc "), String::from("defg ")]
);
}

#[test]
Expand All @@ -369,11 +368,10 @@ mod tests {

let lines = message_buffer.message().unwrap().text(&size);

assert_eq!(lines, vec![
String::from("ab [X]"),
String::from("c 👩 d "),
String::from("fgh ")
]);
assert_eq!(
lines,
vec![String::from("ab [X]"), String::from("c 👩 d "), String::from("fgh ")]
);
}

#[test]
Expand Down
9 changes: 5 additions & 4 deletions alacritty/src/migrate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,11 @@ fn migrate_renames(config: &mut Value) -> Result<(), String> {
};

// draw_bold_text_with_bright_colors -> colors.draw_bold_text_with_bright_colors
move_value(config_table, &["draw_bold_text_with_bright_colors"], &[
"colors",
"draw_bold_text_with_bright_colors",
])?;
move_value(
config_table,
&["draw_bold_text_with_bright_colors"],
&["colors", "draw_bold_text_with_bright_colors"],
)?;

// key_bindings -> keyboard.bindings
move_value(config_table, &["key_bindings"], &["keyboard", "bindings"])?;
Expand Down
2 changes: 1 addition & 1 deletion alacritty/src/renderer/text/glsl3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::display::SizeInfo;
use crate::gl;
use crate::gl::types::*;
use crate::renderer::shader::{ShaderProgram, ShaderVersion};
use crate::renderer::{Error};
use crate::renderer::Error;

use super::atlas::{Atlas, ATLAS_SIZE};
use super::{
Expand Down
26 changes: 16 additions & 10 deletions alacritty_config_derive/tests/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,24 @@ fn config_deserialize() {

// Verify all log messages are correct.
let error_logs = logger.error_logs.lock().unwrap();
assert_eq!(error_logs.as_slice(), [
"Config error: enom_error: unknown variant `HugaBuga`, expected one of `One`, `Two`, \
assert_eq!(
error_logs.as_slice(),
[
"Config error: enom_error: unknown variant `HugaBuga`, expected one of `One`, `Two`, \
`Three`",
"Config error: field1: invalid type: string \"testing\", expected usize",
]);
"Config error: field1: invalid type: string \"testing\", expected usize",
]
);
let warn_logs = logger.warn_logs.lock().unwrap();
assert_eq!(warn_logs.as_slice(), [
"Config warning: field1 has been deprecated; use field2 instead",
"Config warning: enom_error has been deprecated",
"Config warning: gone has been removed; it's gone",
"Unused config key: field3",
]);
assert_eq!(
warn_logs.as_slice(),
[
"Config warning: field1 has been deprecated; use field2 instead",
"Config warning: enom_error has been deprecated",
"Config warning: gone has been removed; it's gone",
"Unused config key: field3",
]
);
}

static mut LOGGER: Option<Logger> = None;
Expand Down
109 changes: 64 additions & 45 deletions alacritty_terminal/src/selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,11 +416,10 @@ mod tests {
let mut selection = Selection::new(SelectionType::Simple, location, Side::Left);
selection.update(location, Side::Right);

assert_eq!(selection.to_range(&term(1, 2)).unwrap(), SelectionRange {
start: location,
end: location,
is_block: false
});
assert_eq!(
selection.to_range(&term(1, 2)).unwrap(),
SelectionRange { start: location, end: location, is_block: false }
);
}

/// Test case of single cell selection.
Expand All @@ -434,11 +433,10 @@ mod tests {
let mut selection = Selection::new(SelectionType::Simple, location, Side::Right);
selection.update(location, Side::Left);

assert_eq!(selection.to_range(&term(1, 2)).unwrap(), SelectionRange {
start: location,
end: location,
is_block: false
});
assert_eq!(
selection.to_range(&term(1, 2)).unwrap(),
SelectionRange { start: location, end: location, is_block: false }
);
}

/// Test adjacent cell selection from left to right.
Expand Down Expand Up @@ -524,11 +522,14 @@ mod tests {
selection.update(Point::new(Line(4), Column(1)), Side::Right);
selection = selection.rotate(&size, &(Line(0)..Line(size.0 as i32)), 4).unwrap();

assert_eq!(selection.to_range(&term(size.0, size.1)).unwrap(), SelectionRange {
start: Point::new(Line(0), Column(0)),
end: Point::new(Line(5), Column(4)),
is_block: false,
});
assert_eq!(
selection.to_range(&term(size.0, size.1)).unwrap(),
SelectionRange {
start: Point::new(Line(0), Column(0)),
end: Point::new(Line(5), Column(4)),
is_block: false,
}
);
}

#[test]
Expand All @@ -539,11 +540,14 @@ mod tests {
selection.update(Point::new(Line(4), Column(1)), Side::Right);
selection = selection.rotate(&size, &(Line(0)..Line(size.0 as i32)), 4).unwrap();

assert_eq!(selection.to_range(&term(size.0, size.1)).unwrap(), SelectionRange {
start: Point::new(Line(0), Column(1)),
end: Point::new(Line(5), Column(3)),
is_block: false,
});
assert_eq!(
selection.to_range(&term(size.0, size.1)).unwrap(),
SelectionRange {
start: Point::new(Line(0), Column(1)),
end: Point::new(Line(5), Column(3)),
is_block: false,
}
);
}

#[test]
Expand All @@ -554,11 +558,14 @@ mod tests {
selection.update(Point::new(Line(4), Column(1)), Side::Right);
selection = selection.rotate(&size, &(Line(0)..Line(size.0 as i32)), 4).unwrap();

assert_eq!(selection.to_range(&term(size.0, size.1)).unwrap(), SelectionRange {
start: Point::new(Line(0), Column(2)),
end: Point::new(Line(5), Column(3)),
is_block: false,
});
assert_eq!(
selection.to_range(&term(size.0, size.1)).unwrap(),
SelectionRange {
start: Point::new(Line(0), Column(2)),
end: Point::new(Line(5), Column(3)),
is_block: false,
}
);
}

#[test]
Expand All @@ -569,11 +576,14 @@ mod tests {
selection.update(Point::new(Line(4), Column(1)), Side::Right);
selection = selection.rotate(&size, &(Line(0)..Line(size.0 as i32)), 4).unwrap();

assert_eq!(selection.to_range(&term(size.0, size.1)).unwrap(), SelectionRange {
start: Point::new(Line(0), Column(2)),
end: Point::new(Line(5), Column(3)),
is_block: true
});
assert_eq!(
selection.to_range(&term(size.0, size.1)).unwrap(),
SelectionRange {
start: Point::new(Line(0), Column(2)),
end: Point::new(Line(5), Column(3)),
is_block: true
}
);
}

#[test]
Expand Down Expand Up @@ -612,11 +622,14 @@ mod tests {
selection.update(Point::new(Line(4), Column(1)), Side::Right);
selection = selection.rotate(&size, &(Line(1)..Line(size.0 as i32 - 1)), 4).unwrap();

assert_eq!(selection.to_range(&term(size.0, size.1)).unwrap(), SelectionRange {
start: Point::new(Line(1), Column(0)),
end: Point::new(Line(3), Column(3)),
is_block: false,
});
assert_eq!(
selection.to_range(&term(size.0, size.1)).unwrap(),
SelectionRange {
start: Point::new(Line(1), Column(0)),
end: Point::new(Line(3), Column(3)),
is_block: false,
}
);
}

#[test]
Expand All @@ -627,11 +640,14 @@ mod tests {
selection.update(Point::new(Line(1), Column(1)), Side::Left);
selection = selection.rotate(&size, &(Line(1)..Line(size.0 as i32 - 1)), -5).unwrap();

assert_eq!(selection.to_range(&term(size.0, size.1)).unwrap(), SelectionRange {
start: Point::new(Line(6), Column(1)),
end: Point::new(Line(8), size.last_column()),
is_block: false,
});
assert_eq!(
selection.to_range(&term(size.0, size.1)).unwrap(),
SelectionRange {
start: Point::new(Line(6), Column(1)),
end: Point::new(Line(8), size.last_column()),
is_block: false,
}
);
}

#[test]
Expand All @@ -642,11 +658,14 @@ mod tests {
selection.update(Point::new(Line(4), Column(1)), Side::Right);
selection = selection.rotate(&size, &(Line(1)..Line(size.0 as i32 - 1)), 4).unwrap();

assert_eq!(selection.to_range(&term(size.0, size.1)).unwrap(), SelectionRange {
start: Point::new(Line(1), Column(2)),
end: Point::new(Line(3), Column(3)),
is_block: true,
});
assert_eq!(
selection.to_range(&term(size.0, size.1)).unwrap(),
SelectionRange {
start: Point::new(Line(1), Column(2)),
end: Point::new(Line(3), Column(3)),
is_block: true,
}
);
}

#[test]
Expand Down

0 comments on commit 7b125ba

Please sign in to comment.