bookmarks are alphabetically sorted by name now, thanks BTreeMap
This commit is contained in:
+4
-4
@@ -1,7 +1,7 @@
|
|||||||
//! handle the config file and bookmarks stored
|
//! handle the config file and bookmarks stored
|
||||||
//! in said config file
|
//! in said config file
|
||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::BTreeMap;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io::{Error, Result};
|
use std::io::{Error, Result};
|
||||||
@@ -15,7 +15,7 @@ use config_parser::{make_padding_string, apply_format};
|
|||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Bookmarks {
|
pub struct Bookmarks {
|
||||||
conf_dir: PathBuf,
|
conf_dir: PathBuf,
|
||||||
bookmarks: HashMap<String, PathBuf>,
|
bookmarks: BTreeMap<String, PathBuf>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Bookmarks {
|
impl Bookmarks {
|
||||||
@@ -25,7 +25,7 @@ impl Bookmarks {
|
|||||||
pub fn new() -> Result<Self> {
|
pub fn new() -> Result<Self> {
|
||||||
let mut bookmarks = Bookmarks {
|
let mut bookmarks = Bookmarks {
|
||||||
conf_dir: PathBuf::new(),
|
conf_dir: PathBuf::new(),
|
||||||
bookmarks: HashMap::<String, PathBuf>::new(),
|
bookmarks: BTreeMap::<String, PathBuf>::new(),
|
||||||
};
|
};
|
||||||
// get home directory path
|
// get home directory path
|
||||||
bookmarks.conf_dir = match config_dir() {
|
bookmarks.conf_dir = match config_dir() {
|
||||||
@@ -56,7 +56,7 @@ impl Bookmarks {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let bookmarks = fs::read_to_string(bookmark_file)?;
|
let bookmarks = fs::read_to_string(bookmark_file)?;
|
||||||
let bookmarks = bookmarks.split("\n");
|
let bookmarks = bookmarks.lines();
|
||||||
for entry in bookmarks {
|
for entry in bookmarks {
|
||||||
let tokens: Vec<&str> = entry.split("=").collect();
|
let tokens: Vec<&str> = entry.split("=").collect();
|
||||||
if tokens.len() != 2 {
|
if tokens.len() != 2 {
|
||||||
|
|||||||
Reference in New Issue
Block a user