Remove CharKind::Newline

This is just a character, and so it seems clearer to refer to it specifically when we want to know if a character is a newline. There was only one case where we relied on Newline being different from Whitespace, and we special-cased that instance. Changing this actually makes us match the behavior of VS Code when double-clicking runs of multiple newlines.

/cc @as-cii

Co-Authored-By: Keith Simmons <keith@the-simmons.net>
This commit is contained in:
Nathan Sobo 2022-03-21 14:14:55 -06:00
parent baeb7d27b8
commit 210fa4c443
3 changed files with 13 additions and 16 deletions

View file

@ -271,7 +271,6 @@ pub(crate) struct DiagnosticEndpoint {
#[derive(Copy, Clone, Eq, PartialEq, PartialOrd, Ord, Debug)]
pub enum CharKind {
Newline,
Punctuation,
Whitespace,
Word,
@ -2259,9 +2258,7 @@ pub fn contiguous_ranges(
}
pub fn char_kind(c: char) -> CharKind {
if c == '\n' {
CharKind::Newline
} else if c.is_whitespace() {
if c.is_whitespace() {
CharKind::Whitespace
} else if c.is_alphanumeric() || c == '_' {
CharKind::Word