mirror of
https://github.com/sayanarijit/xplr.git
synced 2024-10-05 14:58:20 +03:00
Fix linting errors
This commit is contained in:
parent
76224c42e1
commit
053615b041
3
.gitignore
vendored
3
.gitignore
vendored
@ -14,3 +14,6 @@ book/
|
||||
.idea/
|
||||
|
||||
.venv/
|
||||
|
||||
# direnv
|
||||
.direnv/
|
||||
|
33
flake.nix
33
flake.nix
@ -12,7 +12,13 @@
|
||||
|
||||
outputs = { self, nixpkgs, nix, ... }:
|
||||
let
|
||||
systems = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"i686-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
forAllSystems = f: builtins.listToAttrs (map (name: { inherit name; value = f name; }) systems);
|
||||
in
|
||||
{
|
||||
@ -28,7 +34,30 @@
|
||||
lockFile = ./Cargo.lock;
|
||||
};
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
defaultPackage = forAllSystems (system: self.packages.${system}.xplr);
|
||||
devShells = forAllSystems (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
devRequirements = with pkgs; [
|
||||
gcc
|
||||
gnumake
|
||||
clippy
|
||||
rustc
|
||||
cargo
|
||||
rustfmt
|
||||
rust-analyzer
|
||||
];
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
RUST_BACKTRACE = 1;
|
||||
|
||||
buildInputs = devRequirements;
|
||||
packages = devRequirements;
|
||||
};
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
@ -305,7 +305,7 @@ impl App {
|
||||
let hostname = gethostname().to_string_lossy().to_string();
|
||||
|
||||
if let Some(vroot) = vroot.as_ref() {
|
||||
if !pwd.starts_with(&vroot) {
|
||||
if !pwd.starts_with(vroot) {
|
||||
bail!(
|
||||
"{:?} is outside of virtual root {:?}",
|
||||
pwd.to_string_lossy(),
|
||||
@ -822,7 +822,7 @@ impl App {
|
||||
let dir = PathBuf::from(dir).absolutize()?.to_path_buf();
|
||||
|
||||
if let Some(vroot) = &self.vroot.clone() {
|
||||
if !dir.starts_with(&vroot) {
|
||||
if !dir.starts_with(vroot) {
|
||||
return self.log_error(format!(
|
||||
"{:?} is outside of virtual root {:?}",
|
||||
dir.to_string_lossy(),
|
||||
@ -1742,7 +1742,7 @@ impl App {
|
||||
|
||||
pub fn write_pipes(&self, delimiter: char) -> Result<()> {
|
||||
fs::create_dir_all(self.pipe.path.clone())?;
|
||||
fs::write(&self.pipe.msg_in, &[delimiter as u8])?;
|
||||
fs::write(&self.pipe.msg_in, [delimiter as u8])?;
|
||||
|
||||
let selection_str = self.selection_str(delimiter);
|
||||
fs::write(&self.pipe.selection_out, selection_str)?;
|
||||
|
@ -15,7 +15,7 @@ lazy_static! {
|
||||
}
|
||||
|
||||
pub fn explore(parent: &PathBuf, config: &ExplorerConfig) -> Result<Vec<Node>> {
|
||||
let dirs = fs::read_dir(&parent)?;
|
||||
let dirs = fs::read_dir(parent)?;
|
||||
let mut nodes = dirs
|
||||
.filter_map(|d| {
|
||||
d.ok().map(|e| {
|
||||
|
@ -197,7 +197,7 @@ impl std::fmt::Display for Key {
|
||||
_ => c.to_string(),
|
||||
})
|
||||
.unwrap_or_else(|| {
|
||||
serde_yaml::to_value(&self)
|
||||
serde_yaml::to_value(self)
|
||||
.ok()
|
||||
.and_then(|v| v.as_str().map(|v| v.to_string()))
|
||||
.unwrap_or_default()
|
||||
|
@ -14,7 +14,7 @@ fn mime_essence(path: &Path, is_dir: bool) -> String {
|
||||
if is_dir {
|
||||
String::from("inode/directory")
|
||||
} else {
|
||||
mime_guess::from_path(&path)
|
||||
mime_guess::from_path(path)
|
||||
.first()
|
||||
.map(|m| m.essence_str().to_string())
|
||||
.unwrap_or_default()
|
||||
|
@ -60,7 +60,7 @@ pub fn read_all(pipe: &str, delimiter: char) -> Result<Vec<ExternalMsg>> {
|
||||
.read(true)
|
||||
.write(true)
|
||||
.create(false)
|
||||
.open(&pipe)?;
|
||||
.open(pipe)?;
|
||||
|
||||
let mut in_str = String::new();
|
||||
file.read_to_string(&mut in_str)?;
|
||||
|
@ -28,7 +28,7 @@ use tui_input::Input;
|
||||
|
||||
pub fn get_tty() -> Result<fs::File> {
|
||||
let tty = "/dev/tty";
|
||||
match fs::OpenOptions::new().read(true).write(true).open(&tty) {
|
||||
match fs::OpenOptions::new().read(true).write(true).open(tty) {
|
||||
Ok(f) => Ok(f),
|
||||
Err(e) => {
|
||||
bail!(format!("Failed to open {}. {}", tty, e))
|
||||
@ -323,6 +323,7 @@ impl Runner {
|
||||
let backend = CrosstermBackend::new(stdout);
|
||||
let mut terminal = Terminal::new(backend)?;
|
||||
terminal.hide_cursor()?;
|
||||
terminal.clear()?;
|
||||
|
||||
// Threads
|
||||
pwd_watcher::keep_watching(app.pwd.as_ref(), tx_msg_in.clone(), rx_pwd_watcher)?;
|
||||
@ -334,7 +335,7 @@ impl Runner {
|
||||
tx_msg_in.send(app::Task::new(app::MsgIn::External(msg.clone()), None))?;
|
||||
}
|
||||
|
||||
// Refresh once after loading
|
||||
// Refresh screen once after loading
|
||||
tx_msg_in.send(app::Task::new(
|
||||
app::MsgIn::External(app::ExternalMsg::Refresh),
|
||||
None,
|
||||
|
20
src/ui.rs
20
src/ui.rs
@ -809,27 +809,19 @@ fn draw_input_buffer<B: Backend>(
|
||||
.to_owned()
|
||||
.extend(&panel_config.input_and_logs);
|
||||
|
||||
let cursor_offset_left = if config
|
||||
let cursor_offset_left = config
|
||||
.borders
|
||||
.as_ref()
|
||||
.map(|b| b.contains(&Border::Left))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
1
|
||||
} else {
|
||||
0
|
||||
} + app.input.prompt.chars().count() as u16;
|
||||
.unwrap_or(false) as u16
|
||||
+ app.input.prompt.chars().count() as u16;
|
||||
|
||||
let cursor_offset_right = if config
|
||||
let cursor_offset_right = config
|
||||
.borders
|
||||
.as_ref()
|
||||
.map(|b| b.contains(&Border::Right))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
2
|
||||
} else {
|
||||
1
|
||||
};
|
||||
.unwrap_or(false) as u16
|
||||
+ 1;
|
||||
|
||||
let offset_width = cursor_offset_left + cursor_offset_right;
|
||||
let width = layout_size.width.max(offset_width) - offset_width;
|
||||
|
Loading…
Reference in New Issue
Block a user