Enable clippy::single_char_pattern (#8727)

This PR enables the
[`clippy::single_char_pattern`](https://rust-lang.github.io/rust-clippy/master/index.html#/single_char_pattern)
rule and fixes the outstanding violations.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2024-03-02 17:04:59 -05:00 committed by GitHub
parent 12440d5e0d
commit 5935681c5c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 45 additions and 46 deletions

View file

@ -41,7 +41,7 @@ pub fn command_interceptor(mut query: &str, cx: &AppContext) -> Option<CommandIn
//
// For now, you can only do a replace on the % range, and you can
// only use a specific line number range to "go to line"
while query.starts_with(":") {
while query.starts_with(':') {
query = &query[1..];
}
@ -321,16 +321,16 @@ pub fn command_interceptor(mut query: &str, cx: &AppContext) -> Option<CommandIn
"0" => ("0", StartOfDocument.boxed_clone()),
_ => {
if query.starts_with("/") || query.starts_with("?") {
if query.starts_with('/') || query.starts_with('?') {
(
query,
FindCommand {
query: query[1..].to_string(),
backwards: query.starts_with("?"),
backwards: query.starts_with('?'),
}
.boxed_clone(),
)
} else if query.starts_with("%") {
} else if query.starts_with('%') {
(
query,
ReplaceCommand {

View file

@ -135,8 +135,8 @@ fn paste(_: &mut Workspace, action: &Paste, cx: &mut ViewContext<Workspace>) {
} else {
(clipboard_text.to_string(), first_selection_indent_column)
};
let line_mode = to_insert.ends_with("\n");
let is_multiline = to_insert.contains("\n");
let line_mode = to_insert.ends_with('\n');
let is_multiline = to_insert.contains('\n');
if line_mode && !before {
if selection.is_empty() {
@ -480,7 +480,7 @@ mod test {
the_
ˇfox jumps over
_dog"}
.replace("_", " "), // Hack for trailing whitespace
.replace('_', " "), // Hack for trailing whitespace
)
.await;
cx.assert_shared_clipboard("lazy").await;

View file

@ -72,7 +72,7 @@ impl NeovimBackedTestContext {
let test_name = thread
.name()
.expect("thread is not named")
.split(":")
.split(':')
.last()
.unwrap()
.to_string();
@ -122,7 +122,7 @@ impl NeovimBackedTestContext {
}
pub async fn set_shared_state(&mut self, marked_text: &str) {
let mode = if marked_text.contains("»") {
let mode = if marked_text.contains('»') {
Mode::Visual
} else {
Mode::Normal
@ -188,7 +188,7 @@ impl NeovimBackedTestContext {
pub async fn assert_shared_state(&mut self, marked_text: &str) {
self.is_dirty = false;
let marked_text = marked_text.replace("", " ");
let marked_text = marked_text.replace('•', " ");
let neovim = self.neovim_state().await;
let neovim_mode = self.neovim_mode().await;
let editor = self.editor_state();

View file

@ -392,7 +392,7 @@ impl NeovimConnection {
// the content of the selection via the "a register to get the shape correctly.
self.nvim.input("\"aygv").await.unwrap();
let content = self.nvim.command_output("echo getreg('a')").await.unwrap();
let lines = content.split("\n").collect::<Vec<_>>();
let lines = content.split('\n').collect::<Vec<_>>();
let top = cmp::min(selection_row, cursor_row);
let left = cmp::min(selection_col, cursor_col);
for row in top..=cmp::max(selection_row, cursor_row) {