Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if our arg is a dir and prompt for name #121

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions src/iota/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,11 +346,25 @@ impl View {
let mut should_save = false;
{
let buffer = self.buffer.lock().unwrap();
let prefix = "Enter file name: ";

match buffer.file_path {
Some(_) => { should_save = true }
Some(ref p) => {
if p.is_dir() {
// If it's a dir, we still need a file name. This is a tmp fix,
// should ideally be handled better
let path_str = p.to_str().unwrap_or("");

self.overlay = Overlay::SavePrompt {
cursor_x: prefix.len() + path_str.len(),
prefix: prefix,
data: String::from(path_str),
};
} else {
should_save = true
}
},
None => {
let prefix = "Enter file name: ";
self.overlay = Overlay::SavePrompt {
cursor_x: prefix.len(),
prefix: prefix,
Expand Down