Arijit Basu 3 years ago committed by Arijit Basu
parent 4307ba657a
commit 6babfeb3d6

@ -1958,9 +1958,14 @@ impl App {
}
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(()) => {
self.pwd = dir.to_owned();
self.pwd = dir.to_string_lossy().to_string();
if save_history {
self.history = self.history.push(format!("{}/", self.pwd));
}

@ -8,7 +8,7 @@ use serde::Deserialize;
use std::fs;
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>)> {
let mut configv = version.split('.');

@ -106,12 +106,15 @@ pub struct Runner {
impl Runner {
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;
if pwd.is_file() {
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 {

Loading…
Cancel
Save