Skip to content

Commit

Permalink
rename shada to session
Browse files Browse the repository at this point in the history
  • Loading branch information
intarga committed Dec 28, 2023
1 parent 8eb3d64 commit 4987e1a
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
18 changes: 9 additions & 9 deletions helix-loader/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ static CONFIG_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCe

static LOG_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCell::new();

static SHADA_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCell::new();
static SESSION_FILE: once_cell::sync::OnceCell<PathBuf> = once_cell::sync::OnceCell::new();

// Get the current working directory.
// This information is managed internally as the call to std::env::current_dir
Expand Down Expand Up @@ -55,10 +55,10 @@ pub fn initialize_log_file(specified_file: Option<PathBuf>) {
LOG_FILE.set(log_file).ok();
}

pub fn initialize_shada_file(specified_file: Option<PathBuf>) {
let shada_file = specified_file.unwrap_or_else(default_shada_file);
ensure_parent_dir(&shada_file);
SHADA_FILE.set(shada_file).ok();
pub fn initialize_session_file(specified_file: Option<PathBuf>) {
let session_file = specified_file.unwrap_or_else(default_session_file);
ensure_parent_dir(&session_file);
SESSION_FILE.set(session_file).ok();
}

/// A list of runtime directories from highest to lowest priority
Expand Down Expand Up @@ -181,8 +181,8 @@ pub fn log_file() -> PathBuf {
LOG_FILE.get().map(|path| path.to_path_buf()).unwrap()
}

pub fn shada_file() -> PathBuf {
SHADA_FILE.get().map(|path| path.to_path_buf()).unwrap()
pub fn session_file() -> PathBuf {
SESSION_FILE.get().map(|path| path.to_path_buf()).unwrap()
}

pub fn workspace_config_file() -> PathBuf {
Expand All @@ -197,8 +197,8 @@ pub fn default_log_file() -> PathBuf {
cache_dir().join("helix.log")
}

pub fn default_shada_file() -> PathBuf {
state_dir().join("helix.shada")
pub fn default_session_file() -> PathBuf {
state_dir().join("helix.session")
}

/// Merge two TOML documents, merging values from `right` onto `left`
Expand Down
2 changes: 1 addition & 1 deletion helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ toml = "0.7"
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }

# shada
# session persistence
bincode = "2.0.0-rc.3"

# ripgrep for global search
Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use crate::{
config::Config,
job::Jobs,
keymap::Keymaps,
shada,
session,
ui::{self, overlay::overlaid},
};

Expand Down Expand Up @@ -1216,7 +1216,7 @@ impl Application {
}

#[cfg(not(feature = "integration"))]
shada::write_shada_file();
session::write_session_file();

errs
}
Expand Down
8 changes: 4 additions & 4 deletions helix-term/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct Args {
pub verbosity: u64,
pub log_file: Option<PathBuf>,
pub config_file: Option<PathBuf>,
pub shada_file: Option<PathBuf>,
pub session_file: Option<PathBuf>,
pub files: Vec<(PathBuf, Position)>,
pub working_directory: Option<PathBuf>,
}
Expand Down Expand Up @@ -62,9 +62,9 @@ impl Args {
Some(path) => args.log_file = Some(path.into()),
None => anyhow::bail!("--log must specify a path to write"),
},
"--shada" => match argv.next().as_deref() {
Some(path) => args.shada_file = Some(path.into()),
None => anyhow::bail!("--shada must specify a path to write"),
"--session-file" => match argv.next().as_deref() {
Some(path) => args.session_file = Some(path.into()),
None => anyhow::bail!("--session-file must specify a path to write"),
},
"-w" | "--working-dir" => match argv.next().as_deref() {
Some(path) => {
Expand Down
2 changes: 1 addition & 1 deletion helix-term/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ pub mod config;
pub mod health;
pub mod job;
pub mod keymap;
pub mod shada;
pub mod session;
pub mod ui;
use std::path::Path;

Expand Down
4 changes: 2 additions & 2 deletions helix-term/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ FLAGS:
-v Increases logging verbosity each use for up to 3 times
--log <file> Specifies a file to use for logging
(default file: {})
--shada <file> Specifies a file to use for shared data
--session-file <file> Specifies a file to use for shared data
-V, --version Prints version information
--vsplit Splits all given files vertically into different windows
--hsplit Splits all given files horizontally into different windows
Expand All @@ -81,7 +81,7 @@ FLAGS:

helix_loader::initialize_config_file(args.config_file.clone());
helix_loader::initialize_log_file(args.log_file.clone());
helix_loader::initialize_shada_file(args.shada_file.clone());
helix_loader::initialize_session_file(args.session_file.clone());

// Help has a higher priority and should be handled separately.
if args.display_help {
Expand Down
8 changes: 4 additions & 4 deletions helix-term/src/shada.rs → helix-term/src/session.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use bincode::{encode_into_std_write, Decode, Encode};
use helix_loader::{shada_file, VERSION_AND_GIT_HASH};
use helix_loader::{session_file, VERSION_AND_GIT_HASH};
// use helix_view::view::ViewPosition;
use std::{
fs::File,
Expand Down Expand Up @@ -55,14 +55,14 @@ fn generate_header() -> Entry {
}
}

pub fn write_shada_file() {
pub fn write_session_file() {
// TODO: merge existing file if exists

// TODO: do something about this unwrap
let mut shada_file = File::create(shada_file()).unwrap();
let mut session_file = File::create(session_file()).unwrap();

let header = generate_header();

// TODO: do something about this unwrap
encode_into_std_write(&header, &mut shada_file, bincode::config::standard()).unwrap();
encode_into_std_write(&header, &mut session_file, bincode::config::standard()).unwrap();
}

0 comments on commit 4987e1a

Please sign in to comment.