cleaned up all compiler warnings
This commit is contained in:
6
flake.lock
generated
6
flake.lock
generated
@@ -20,11 +20,11 @@
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1771369470,
|
||||
"narHash": "sha256-0NBlEBKkN3lufyvFegY4TYv5mCNHbi5OmBDrzihbBMQ=",
|
||||
"lastModified": 1771848320,
|
||||
"narHash": "sha256-0MAd+0mun3K/Ns8JATeHT1sX28faLII5hVLq0L3BdZU=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "0182a361324364ae3f436a63005877674cf45efb",
|
||||
"rev": "2fc6539b481e1d2569f25f8799236694180c0993",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -3,35 +3,6 @@ use std::sync::LazyLock;
|
||||
use termios::{LocalFlags, Termios};
|
||||
|
||||
use crate::prelude::*;
|
||||
///
|
||||
/// The previous state of the terminal options.
|
||||
///
|
||||
/// This variable stores the terminal settings at the start of the program and
|
||||
/// restores them when the program exits. It is initialized exactly once at the
|
||||
/// start of the program and accessed exactly once at the end of the program. It
|
||||
/// will not be mutated or accessed under any other circumstances.
|
||||
///
|
||||
/// This ended up being necessary because wrapping Termios in a thread-safe way
|
||||
/// was unreasonably tricky.
|
||||
///
|
||||
/// The possible states of this variable are:
|
||||
/// - `None`: The terminal options have not been set yet (before
|
||||
/// initialization).
|
||||
/// - `Some(None)`: There were no terminal options to save (i.e., no terminal
|
||||
/// input detected).
|
||||
/// - `Some(Some(Termios))`: The terminal options (as `Termios`) have been
|
||||
/// saved.
|
||||
///
|
||||
/// **Important:** This static variable is mutable and accessed via unsafe code.
|
||||
/// It is only safe to use because:
|
||||
/// - It is set once during program startup and accessed once during program
|
||||
/// exit.
|
||||
/// - It is not mutated or accessed after the initial setup and final read.
|
||||
///
|
||||
/// **Caution:** Future changes to this code should respect these constraints to
|
||||
/// ensure safety. Modifying or accessing this variable outside the defined
|
||||
/// lifecycle could lead to undefined behavior.
|
||||
pub(crate) static mut SAVED_TERMIOS: Option<Option<Termios>> = None;
|
||||
|
||||
pub static TTY_FILENO: LazyLock<RawFd> = LazyLock::new(|| {
|
||||
open("/dev/tty", OFlag::O_RDWR, Mode::empty()).expect("Failed to open /dev/tty")
|
||||
|
||||
@@ -15,7 +15,6 @@ use crate::{
|
||||
error::{ShErr, ShErrKind, ShResult},
|
||||
utils::CharDequeUtils,
|
||||
},
|
||||
prelude::*,
|
||||
};
|
||||
|
||||
pub const KEYWORDS: [&str; 16] = [
|
||||
|
||||
@@ -441,3 +441,9 @@ impl Highlighter {
|
||||
.replace(markers::OPERATOR, "\x1b[35m");
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Highlighter {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,14 +9,11 @@ use std::{
|
||||
time::{Duration, SystemTime, UNIX_EPOCH},
|
||||
};
|
||||
|
||||
use crate::prelude::*;
|
||||
use crate::{
|
||||
libsh::error::{ShErr, ShErrKind, ShResult},
|
||||
readline::linebuf::LineBuf,
|
||||
};
|
||||
|
||||
use super::vicmd::Direction; // surprisingly useful
|
||||
|
||||
#[derive(Default, Clone, Copy, Debug)]
|
||||
pub enum SearchKind {
|
||||
Fuzzy,
|
||||
@@ -215,7 +212,7 @@ pub struct History {
|
||||
search_mask: Vec<HistEntry>,
|
||||
no_matches: bool,
|
||||
pub cursor: usize,
|
||||
search_direction: Direction,
|
||||
//search_direction: Direction,
|
||||
ignore_dups: bool,
|
||||
max_size: Option<u32>,
|
||||
}
|
||||
@@ -242,7 +239,7 @@ impl History {
|
||||
search_mask,
|
||||
no_matches: false,
|
||||
cursor,
|
||||
search_direction: Direction::Backward,
|
||||
//search_direction: Direction::Backward,
|
||||
ignore_dups,
|
||||
max_size: Some(max_hist as u32),
|
||||
})
|
||||
|
||||
@@ -857,18 +857,15 @@ pub struct TermWriter {
|
||||
out: RawFd,
|
||||
pub t_cols: Col, // terminal width
|
||||
buffer: String,
|
||||
w_calc: Box<dyn WidthCalculator>,
|
||||
}
|
||||
|
||||
impl TermWriter {
|
||||
pub fn new(out: RawFd) -> Self {
|
||||
let w_calc = width_calculator();
|
||||
let (t_cols, _) = get_win_size(out);
|
||||
Self {
|
||||
out,
|
||||
t_cols,
|
||||
buffer: String::new(),
|
||||
w_calc,
|
||||
}
|
||||
}
|
||||
pub fn get_cursor_movement(&self, old: Pos, new: Pos) -> ShResult<String> {
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
use std::iter::Peekable;
|
||||
use std::str::Chars;
|
||||
|
||||
use nix::NixPath;
|
||||
use unicode_segmentation::UnicodeSegmentation;
|
||||
|
||||
use super::keys::{KeyCode as K, KeyEvent as E, ModKeys as M};
|
||||
@@ -994,7 +993,7 @@ impl ViNormal {
|
||||
}
|
||||
};
|
||||
|
||||
chars.peek().is_some();
|
||||
let _ = chars; // suppresses unused warnings, creates an error if we decide to use chars later
|
||||
|
||||
let verb_ref = verb.as_ref().map(|v| &v.1);
|
||||
let motion_ref = motion.as_ref().map(|m| &m.1);
|
||||
@@ -1659,7 +1658,7 @@ impl ViVisual {
|
||||
}
|
||||
};
|
||||
|
||||
chars.peek().is_some();
|
||||
let _ = chars; // suppresses unused warnings, creates an error if we decide to use chars later
|
||||
|
||||
let verb_ref = verb.as_ref().map(|v| &v.1);
|
||||
let motion_ref = motion.as_ref().map(|m| &m.1);
|
||||
|
||||
Reference in New Issue
Block a user