chore: Fix several style lints (#17488)

It's not comprehensive enough to start linting on `style` group, but
hey, it's a start.

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2024-09-06 11:58:39 +02:00 committed by GitHub
parent 93249fc82b
commit e6c1c51b37
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
361 changed files with 3530 additions and 3587 deletions

View file

@ -11,14 +11,14 @@ use gpui::{px, Modifiers, MouseButton, MouseMoveEvent, Pixels, Point, ScrollWhee
use crate::TerminalSize;
enum MouseFormat {
SGR,
Sgr,
Normal(bool),
}
impl MouseFormat {
fn from_mode(mode: TermMode) -> Self {
if mode.contains(TermMode::SGR_MOUSE) {
MouseFormat::SGR
MouseFormat::Sgr
} else if mode.contains(TermMode::UTF8_MOUSE) {
MouseFormat::Normal(true)
} else {
@ -77,10 +77,7 @@ impl AlacMouseButton {
}
fn is_other(&self) -> bool {
match self {
AlacMouseButton::Other => true,
_ => false,
}
matches!(self, AlacMouseButton::Other)
}
}
@ -219,7 +216,7 @@ fn mouse_report(
}
match format {
MouseFormat::SGR => {
MouseFormat::Sgr => {
Some(sgr_mouse_report(point, button as u8 + mods, pressed).into_bytes())
}
MouseFormat::Normal(utf8) => {

View file

@ -823,9 +823,9 @@ impl Terminal {
let mut min_index = point;
loop {
let new_min_index = min_index.sub(term, Boundary::Cursor, 1);
if new_min_index == min_index {
break;
} else if term.grid().index(new_min_index).hyperlink() != link {
if new_min_index == min_index
|| term.grid().index(new_min_index).hyperlink() != link
{
break;
} else {
min_index = new_min_index
@ -835,9 +835,9 @@ impl Terminal {
let mut max_index = point;
loop {
let new_max_index = max_index.add(term, Boundary::Cursor, 1);
if new_max_index == max_index {
break;
} else if term.grid().index(new_max_index).hyperlink() != link {
if new_max_index == max_index
|| term.grid().index(new_max_index).hyperlink() != link
{
break;
} else {
max_index = new_max_index
@ -1410,12 +1410,10 @@ impl Terminal {
&& !e.shift
{
self.pty_tx.notify(alt_scroll(scroll_lines))
} else {
if scroll_lines != 0 {
let scroll = AlacScroll::Delta(scroll_lines);
} else if scroll_lines != 0 {
let scroll = AlacScroll::Delta(scroll_lines);
self.events.push_back(InternalEvent::Scroll(scroll));
}
self.events.push_back(InternalEvent::Scroll(scroll));
}
}
}
@ -1496,7 +1494,7 @@ impl Terminal {
let process_name = format!(
"{}{}",
fpi.name,
if argv.len() >= 1 {
if !argv.is_empty() {
format!(" {}", (argv[1..]).join(" "))
} else {
"".to_string()
@ -1612,16 +1610,16 @@ fn task_summary(task: &TaskState, error_code: Option<i32>) -> (bool, String, Str
/// The library
///
/// * does not increment inner grid cursor's _lines_ on `input` calls
/// (but displaying the lines correctly and incrementing cursor's columns)
/// (but displaying the lines correctly and incrementing cursor's columns)
///
/// * ignores `\n` and \r` character input, requiring the `newline` call instead
///
/// * does not alter grid state after `newline` call
/// so its `bottommost_line` is always the same additions, and
/// the cursor's `point` is not updated to the new line and column values
/// so its `bottommost_line` is always the same additions, and
/// the cursor's `point` is not updated to the new line and column values
///
/// * ??? there could be more consequences, and any further "proper" streaming from the PTY might bug and/or panic.
/// Still, concequent `append_text_to_term` invocations are possible and display the contents correctly.
/// Still, concequent `append_text_to_term` invocations are possible and display the contents correctly.
///
/// Despite the quirks, this is the simplest approach to appending text to the terminal: its alternative, `grid_mut` manipulations,
/// do not properly set the scrolling state and display odd text after appending; also those manipulations are more tedious and error-prone.