Ran the codebase through rustfmt

This commit is contained in:
2026-02-23 23:32:46 -05:00
parent 367218d3e8
commit cab7a0fea7
27 changed files with 254 additions and 240 deletions

View File

@@ -6,7 +6,7 @@ use tempfile::TempDir;
use crate::prompt::readline::complete::Completer;
use crate::prompt::readline::markers;
use crate::state::{VarFlags, write_logic, write_vars};
use crate::state::{write_logic, write_vars, VarFlags};
use super::*;
@@ -192,12 +192,10 @@ fn complete_filename_with_slash() {
// Should complete files in subdir/
if result.is_some() {
assert!(
completer
.candidates
.iter()
.any(|c| c.contains("nested.txt"))
);
assert!(completer
.candidates
.iter()
.any(|c| c.contains("nested.txt")));
}
}
@@ -704,12 +702,10 @@ fn complete_special_characters_in_filename() {
if result.is_some() {
// Should handle special chars in filenames
assert!(
completer
.candidates
.iter()
.any(|c| c.contains("file-with-dash") || c.contains("file_with_underscore"))
);
assert!(completer
.candidates
.iter()
.any(|c| c.contains("file-with-dash") || c.contains("file_with_underscore")));
}
}

View File

@@ -1,6 +1,6 @@
use std::collections::HashSet;
use crate::expand::{DUB_QUOTE, VAR_SUB, perform_param_expansion};
use crate::expand::{perform_param_expansion, DUB_QUOTE, VAR_SUB};
use crate::state::VarFlags;
use super::*;

View File

@@ -4,9 +4,8 @@ use super::*;
use crate::expand::{expand_aliases, unescape_str};
use crate::libsh::error::{Note, ShErr, ShErrKind};
use crate::parse::{
NdRule, Node, ParseStream,
lex::{LexFlags, LexStream, Tk, TkRule},
node_operation,
node_operation, NdRule, Node, ParseStream,
};
use crate::state::{write_logic, write_vars};

View File

@@ -6,12 +6,12 @@ use crate::{
term::{Style, Styled},
},
prompt::readline::{
FernVi,
history::History,
keys::{KeyCode, KeyEvent, ModKeys},
linebuf::LineBuf,
term::{KeyReader, LineWriter, raw_mode},
term::{raw_mode, KeyReader, LineWriter},
vimode::{ViInsert, ViMode, ViNormal},
FernVi,
},
};
@@ -175,9 +175,9 @@ impl LineWriter for TestWriter {
Ok(())
}
fn send_bell(&mut self) -> ShResult<()> {
Ok(())
}
fn send_bell(&mut self) -> ShResult<()> {
Ok(())
}
}
// NOTE: FernVi structure has changed significantly and readline() method no
@@ -605,31 +605,27 @@ fn editor_delete_line_up() {
#[test]
fn editor_insert_at_line_start() {
// I should move cursor to position 0 when line starts with non-whitespace
assert_eq!(
normal_cmd("I", "hello world", 5),
("hello world".into(), 0)
);
assert_eq!(normal_cmd("I", "hello world", 5), ("hello world".into(), 0));
// I should skip leading whitespace
assert_eq!(
normal_cmd("I", " hello world", 8),
(" hello world".into(), 2)
);
// I should move to the first non-whitespace on the current line in a multiline buffer
// I should move to the first non-whitespace on the current line in a multiline
// buffer
assert_eq!(
normal_cmd("I", "first line\nsecond line", 14),
("first line\nsecond line".into(), 11)
);
// I should land on position 0 when cursor is already at 0
assert_eq!(
normal_cmd("I", "hello", 0),
("hello".into(), 0)
);
assert_eq!(normal_cmd("I", "hello", 0), ("hello".into(), 0));
}
#[test]
fn editor_f_char_from_position_zero() {
// f<char> at position 0 should skip the cursor and find the next occurrence
// Regression: previously at pos 0, f would match the char under the cursor itself
// Regression: previously at pos 0, f would match the char under the cursor
// itself
assert_eq!(
normal_cmd("fa", "abcaef", 0),
("abcaef".into(), 3) // should find second 'a', not the 'a' at position 0

View File

@@ -1,8 +1,8 @@
use std::sync::Arc;
use crate::parse::{
NdRule, Node, ParseStream, Redir, RedirType,
lex::{LexFlags, LexStream},
NdRule, Node, ParseStream, Redir, RedirType,
};
use crate::procio::{IoFrame, IoMode, IoStack};

View File

@@ -1,5 +1,5 @@
use std::path::PathBuf;
use crate::state::{LogTab, MetaTab, ScopeStack, ShellParam, VarFlags, VarTab};
use std::path::PathBuf;
// ============================================================================
// ScopeStack Tests - Variable Scoping
@@ -11,8 +11,8 @@ fn scopestack_new() {
// Should start with one global scope
assert!(stack.var_exists("PATH") || !stack.var_exists("PATH")); // Just check
// it doesn't
// panic
// it doesn't
// panic
}
#[test]
@@ -296,13 +296,21 @@ fn scopestack_local_var_mutation() {
// `foo="bar"` — reassign without LOCAL flag (plain assignment)
stack.set_var("foo", "bar", VarFlags::NONE);
assert_eq!(stack.get_var("foo"), "bar", "Local var should be mutated in place");
assert_eq!(
stack.get_var("foo"),
"bar",
"Local var should be mutated in place"
);
// Ascend back to global
stack.ascend();
// foo should not exist in global scope
assert_eq!(stack.get_var("foo"), "", "Local var should not leak to global scope");
assert_eq!(
stack.get_var("foo"),
"",
"Local var should not leak to global scope"
);
}
#[test]
@@ -318,13 +326,21 @@ fn scopestack_local_var_uninitialized() {
// `foo="bar"` — assign a value later
stack.set_var("foo", "bar", VarFlags::NONE);
assert_eq!(stack.get_var("foo"), "bar", "Uninitialized local should be assignable");
assert_eq!(
stack.get_var("foo"),
"bar",
"Uninitialized local should be assignable"
);
// Ascend back to global
stack.ascend();
// foo should not exist in global scope
assert_eq!(stack.get_var("foo"), "", "Local var should not leak to global scope");
assert_eq!(
stack.get_var("foo"),
"",
"Local var should not leak to global scope"
);
}
// ============================================================================
@@ -740,11 +756,14 @@ fn dirstack_pushd_rotation_with_cwd() {
assert_eq!(new_cwd, Some(PathBuf::from("/var")));
let remaining: Vec<_> = meta.dirs().iter().collect();
assert_eq!(remaining, vec![
&PathBuf::from("/etc"),
&PathBuf::from("/home"),
&PathBuf::from("/tmp"),
]);
assert_eq!(
remaining,
vec![
&PathBuf::from("/etc"),
&PathBuf::from("/home"),
&PathBuf::from("/tmp"),
]
);
}
#[test]
@@ -821,10 +840,10 @@ fn dirstack_popd_plus_n_offset() {
assert_eq!(removed, Some(PathBuf::from("/var")));
let remaining: Vec<_> = meta.dirs().iter().collect();
assert_eq!(remaining, vec![
&PathBuf::from("/tmp"),
&PathBuf::from("/etc"),
]);
assert_eq!(
remaining,
vec![&PathBuf::from("/tmp"), &PathBuf::from("/etc"),]
);
}
#[test]