Arijit Basu 2021-07-05 11:21:12 +05:30 committed by Arijit Basu
parent 4307ba657a
commit 6babfeb3d6
3 changed files with 13 additions and 5 deletions

View File

@ -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));
} }

View File

@ -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('.');

View File

@ -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 {