mirror of
https://github.com/sayanarijit/xplr
synced 2024-11-10 07:10:45 +00:00
Minor improvements
Fixes: https://github.com/sayanarijit/xplr/issues/284 Closes: https://github.com/sayanarijit/xplr/issues/286 Partially fixes: https://github.com/sayanarijit/xplr/issues/285
This commit is contained in:
parent
4307ba657a
commit
6babfeb3d6
@ -1958,9 +1958,14 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn change_directory(mut self, dir: &str, save_history: bool) -> Result<Self> {
|
fn change_directory(mut self, dir: &str, save_history: bool) -> Result<Self> {
|
||||||
match env::set_current_dir(dir) {
|
let mut dir = PathBuf::from(dir);
|
||||||
|
if dir.is_relative() {
|
||||||
|
dir = PathBuf::from(self.pwd()).join(dir);
|
||||||
|
}
|
||||||
|
|
||||||
|
match env::set_current_dir(&dir) {
|
||||||
Ok(()) => {
|
Ok(()) => {
|
||||||
self.pwd = dir.to_owned();
|
self.pwd = dir.to_string_lossy().to_string();
|
||||||
if save_history {
|
if save_history {
|
||||||
self.history = self.history.push(format!("{}/", self.pwd));
|
self.history = self.history.push(format!("{}/", self.pwd));
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ use serde::Deserialize;
|
|||||||
use std::fs;
|
use std::fs;
|
||||||
|
|
||||||
const DEFAULT_LUA_SCRIPT: &str = include_str!("init.lua");
|
const DEFAULT_LUA_SCRIPT: &str = include_str!("init.lua");
|
||||||
const UPGRADE_GUIDE_LINK: &str = "https://github.com/sayanarijit/xplr/wiki/Upgrade-Guide";
|
const UPGRADE_GUIDE_LINK: &str = "https://arijitbasu.in/xplr/en/upgrade-guide.html";
|
||||||
|
|
||||||
fn parse_version(version: &str) -> Result<(u16, u16, u16, Option<u16>)> {
|
fn parse_version(version: &str) -> Result<(u16, u16, u16, Option<u16>)> {
|
||||||
let mut configv = version.split('.');
|
let mut configv = version.split('.');
|
||||||
|
@ -106,12 +106,15 @@ pub struct Runner {
|
|||||||
|
|
||||||
impl Runner {
|
impl Runner {
|
||||||
pub(crate) fn new(path: Option<PathBuf>) -> Result<Self> {
|
pub(crate) fn new(path: Option<PathBuf>) -> Result<Self> {
|
||||||
let mut pwd = path.unwrap_or_else(|| ".".into()).canonicalize()?;
|
let basedir = std::env::current_dir()?;
|
||||||
|
let mut pwd = path
|
||||||
|
.map(|p| if p.is_relative() { basedir.join(p) } else { p })
|
||||||
|
.unwrap_or_else(|| basedir.clone());
|
||||||
let mut focused_path = None;
|
let mut focused_path = None;
|
||||||
|
|
||||||
if pwd.is_file() {
|
if pwd.is_file() {
|
||||||
focused_path = pwd.file_name().map(|p| p.into());
|
focused_path = pwd.file_name().map(|p| p.into());
|
||||||
pwd = pwd.parent().map(|p| p.into()).unwrap_or_else(|| ".".into());
|
pwd = pwd.parent().map(|p| p.into()).unwrap_or(basedir);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(Self {
|
Ok(Self {
|
||||||
|
Loading…
Reference in New Issue
Block a user