basic file handling #7
Loading…
Reference in New Issue
No description provided.
Delete Branch "emma/breed:main"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Very, very, very good in general but I had some questions.
@ -326,12 +335,60 @@ impl State {
}
}
fn write_buffer(&mut self, file: OsString) -> std::result::Result<(), String> {
This is a very good function, but can we make this function return
std::io::Result<()>
instead? I think that displaying the error as a string should be the job of whatever command is saving the file.@ -334,0 +361,4 @@
None => return Ok(()),
};
for command in commands.clone().iter() {
I don't think that splitting up commands into chars before processing like this is the right approach. For example,
q!
would be treated as two separate commands despite it performing a different operation thanq
.I think if we were going to add commands like
q!
orwq
than those should be matched on the corresponding branches. Makingwrite_buffer()
as a separate function definitely makes doing that easier, so that was the right call.I was planning on making the Iterator peekable, so we could do:
or more likely
match
ing the!
, but idk if that would be good or notI think it's much more straight-forward just to match the strings.
Probably. I’ll try that out
@ -334,0 +363,4 @@
for command in commands.clone().iter() {
match command {
'q' => self.quit = true,
If "q" is given multiple command parts, it still quits without issuing a warning. I'm not sure if this should exit silently even when given more arguments than expected. What do you think?
Edit: how we decide to do this now will help us handle argc differences in the future.
It definitely should not exit silently, it should error, stating that
:q
doesn’t take arguments (on its own).@ -334,0 +370,4 @@
if let Some(part) = self.file.clone() {
handle = part;
} else {
handle = match command_parts.get(1) {
Same kind of deal here; what if there is more than one argument?