@@ -888,7 +888,7 @@ pub fn scroll(cx: &mut Context, offset: usize, direction: Direction) {
888888 .primary()
889889 .cursor(doc.text().slice(..)),
890890 );
891− let doc_last_line = doc.text().len_lines() - 1;
891+ let doc_last_line = doc.text().len_lines().saturating_sub(1);
892892
893893 let last_line = view.last_line(doc);
894894
@@ -1509,18 +1509,19 @@ mod cmd {
15091509 return Ok(());
15101510 }
15111511
1512+ let arg = args.get(0).context("argument missing")?.to_ascii_lowercase();
1513+
15121514 // Attempt to parse argument as a line ending.
1513− let line_ending = match args.get(0) {
1515+ let line_ending = match arg {
15141516 // We check for CR first because it shares a common prefix with CRLF.
1515− Some(arg) if "cr".starts_with(&arg.to_lowercase()) => Some(CR),
1516− Some(arg) if "crlf".starts_with(&arg.to_lowercase()) => Some(Crlf),
1517− Some(arg) if "lf".starts_with(&arg.to_lowercase()) => Some(LF),
1518− Some(arg) if "ff".starts_with(&arg.to_lowercase()) => Some(FF),
1519− Some(arg) if "nel".starts_with(&arg.to_lowercase()) => Some(Nel),
1520− _ => None,
1517+ arg if arg.starts_with("cr") => CR,
1518+ arg if arg.starts_with("crlf") => Crlf,
1519+ arg if arg.starts_with("lf") => LF,
1520+ arg if arg.starts_with("ff") => FF,
1521+ arg if arg.starts_with("nel") => Nel,
1522+ _ => bail!("invalid line ending")
15211523 };
15221524
1523− let line_ending = line_ending.context("invalid line ending")?;
15241525 doc_mut!(cx.editor).line_ending = line_ending;
15251526 Ok(())
15261527 }