summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--helix-term/src/commands.rs19
-rw-r--r--helix-term/src/ui/mod.rs2
2 files changed, 11 insertions, 10 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index d3c5dd76..82d310ec 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -888,7 +888,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
.primary()
.cursor(doc.text().slice(..)),
);
- let doc_last_line = doc.text().len_lines() - 1;
+ let doc_last_line = doc.text().len_lines().saturating_sub(1);
let last_line = view.last_line(doc);
@@ -1509,18 +1509,19 @@ mod cmd {
return Ok(());
}
+ let arg = args.get(0).context("argument missing")?.to_ascii_lowercase();
+
// Attempt to parse argument as a line ending.
- let line_ending = match args.get(0) {
+ let line_ending = match arg {
// We check for CR first because it shares a common prefix with CRLF.
- Some(arg) if "cr".starts_with(&arg.to_lowercase()) => Some(CR),
- Some(arg) if "crlf".starts_with(&arg.to_lowercase()) => Some(Crlf),
- Some(arg) if "lf".starts_with(&arg.to_lowercase()) => Some(LF),
- Some(arg) if "ff".starts_with(&arg.to_lowercase()) => Some(FF),
- Some(arg) if "nel".starts_with(&arg.to_lowercase()) => Some(Nel),
- _ => None,
+ arg if arg.starts_with("cr") => CR,
+ arg if arg.starts_with("crlf") => Crlf,
+ arg if arg.starts_with("lf") => LF,
+ arg if arg.starts_with("ff") => FF,
+ arg if arg.starts_with("nel") => Nel,
+ _ => bail!("invalid line ending")
};
- let line_ending = line_ending.context("invalid line ending")?;
doc_mut!(cx.editor).line_ending = line_ending;
Ok(())
}
diff --git a/helix-term/src/ui/mod.rs b/helix-term/src/ui/mod.rs
index d1af0e48..390f1a66 100644
--- a/helix-term/src/ui/mod.rs
+++ b/helix-term/src/ui/mod.rs
@@ -76,7 +76,7 @@ pub fn regex_prompt(
pub fn file_picker(root: PathBuf) -> FilePicker<PathBuf> {
use ignore::Walk;
use std::time;
- let files = Walk::new(root.clone()).filter_map(|entry| {
+ let files = Walk::new(&root).filter_map(|entry| {
let entry = entry.ok()?;
// Path::is_dir() traverses symlinks, so we use it over DirEntry::is_dir
if entry.path().is_dir() {