Skip to content

Commit

Permalink
refactor: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
dxrcy committed Dec 19, 2024
1 parent 87c907e commit c4f12fe
Showing 1 changed file with 15 additions and 18 deletions.
33 changes: 15 additions & 18 deletions src/debugger/source.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::fmt;
use std::fs::{self, File};
use std::io::{self, BufRead, BufReader, IsTerminal, Read, Write};
use std::path::PathBuf;

use console::Key;

Expand Down Expand Up @@ -61,8 +60,6 @@ struct TerminalHistory {
index: usize,
/// `None` indicates failure to open file
file: Option<File>,
// /// `None` indicates failure to retrieve file path
// path: PathBuf,
}

fn echo_command_prompt(command: Option<&str>) {
Expand Down Expand Up @@ -443,6 +440,21 @@ impl TerminalHistory {
self.list.push(command);
}

fn read_file(file: Option<&mut File>) -> Vec<String> {
let Some(file) = file else {
return Vec::new();
};
let mut history = Vec::new();
for line in BufReader::new(file).lines() {
let Ok(line) = line else {
Self::report_error("Failed to read from file");
break;
};
history.push(line);
}
return history;
}

fn get_file() -> Option<File> {
let Some(parent_dir) = dirs_next::cache_dir() else {
Self::report_error(format_args!(
Expand Down Expand Up @@ -481,21 +493,6 @@ impl TerminalHistory {
}
}

fn read_file(file: Option<&mut File>) -> Vec<String> {
let Some(file) = file else {
return Vec::new();
};
let mut history = Vec::new();
for line in BufReader::new(file).lines() {
let Ok(line) = line else {
Self::report_error("Failed to read from file");
break;
};
history.push(line);
}
return history;
}

fn report_error(message: impl fmt::Display) {
dprintln!(
Always,
Expand Down

0 comments on commit c4f12fe

Please sign in to comment.