refactoring

pull/909/head
adamnemecek 2025-10-26 12:29:48 +07:00
parent 2ec5fe7948
commit 62ad5cecf9
4 changed files with 49 additions and 58 deletions

@ -138,14 +138,14 @@ enum EnteredDelimiter<'s, 'v> {
impl fmt::Debug for EnteredDelimiter<'_, '_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let desc = match self {
EnteredDelimiter::PopEither((lhs_delims, rhs_delims)) => {
Self::PopEither((lhs_delims, rhs_delims)) => {
format!(
"PopEither(lhs count: {}, rhs count: {})",
lhs_delims.size(),
rhs_delims.size()
)
}
EnteredDelimiter::PopBoth(_) => "PopBoth".to_owned(),
Self::PopBoth(_) => "PopBoth".to_owned(),
};
f.write_str(&desc)
}

@ -32,11 +32,7 @@ struct File<'f> {
}
impl<'f> File<'f> {
fn with_sections(
language: &'f FileFormat,
path: &'f str,
chunks: Vec<Vec<Line<'f>>>,
) -> Self {
fn with_sections(language: &'f FileFormat, path: &'f str, chunks: Vec<Vec<Line<'f>>>) -> Self {
File {
language,
path,

@ -525,54 +525,51 @@ fn from_emacs_mode_header(src: &str) -> Option<Language> {
(Some(cap), _) | (_, Some(cap)) => cap[1].into(),
_ => "".into(),
};
let lang = match mode_name.to_ascii_lowercase().trim() {
"ada" => Some(Ada),
"c" => Some(C),
"clojure" => Some(Clojure),
"csharp" => Some(CSharp),
"css" => Some(Css),
"dart" => Some(Dart),
"c++" => Some(CPlusPlus),
"elixir" => Some(Elixir),
"elm" => Some(Elm),
"elvish" => Some(Elvish),
"emacs-lisp" => Some(EmacsLisp),
"fsharp" => Some(FSharp),
"gleam" => Some(Gleam),
"go" => Some(Go),
"haskell" => Some(Haskell),
"hcl" => Some(Hcl),
"html" => Some(Html),
"janet" => Some(Janet),
"java" => Some(Java),
"js" | "js2" => Some(JavaScript),
"lisp" => Some(CommonLisp),
"nxml" => Some(Xml),
"objc" => Some(ObjC),
"perl" => Some(Perl),
"python" => Some(Python),
"racket" => Some(Racket),
"rjsx" => Some(JavascriptJsx),
"ruby" => Some(Ruby),
"rust" => Some(Rust),
"scala" => Some(Scala),
"scss" => Some(Scss),
"sh" => Some(Bash),
"solidity" => Some(Solidity),
"sql" => Some(Sql),
"swift" => Some(Swift),
"toml" => Some(Toml),
"tuareg" => Some(OCaml),
"typescript" => Some(TypeScript),
"verilog" => Some(Verilog),
"vhdl" => Some(Vhdl),
"yaml" => Some(Yaml),
"zig" => Some(Zig),
_ => None,
};
if lang.is_some() {
return lang;
}
return Some(match mode_name.to_ascii_lowercase().trim() {
"ada" => Ada,
"c" => C,
"clojure" => Clojure,
"csharp" => CSharp,
"css" => Css,
"dart" => Dart,
"c++" => CPlusPlus,
"elixir" => Elixir,
"elm" => Elm,
"elvish" => Elvish,
"emacs-lisp" => EmacsLisp,
"fsharp" => FSharp,
"gleam" => Gleam,
"go" => Go,
"haskell" => Haskell,
"hcl" => Hcl,
"html" => Html,
"janet" => Janet,
"java" => Java,
"js" | "js2" => JavaScript,
"lisp" => CommonLisp,
"nxml" => Xml,
"objc" => ObjC,
"perl" => Perl,
"python" => Python,
"racket" => Racket,
"rjsx" => JavascriptJsx,
"ruby" => Ruby,
"rust" => Rust,
"scala" => Scala,
"scss" => Scss,
"sh" => Bash,
"solidity" => Solidity,
"sql" => Sql,
"swift" => Swift,
"toml" => Toml,
"tuareg" => OCaml,
"typescript" => TypeScript,
"verilog" => Verilog,
"vhdl" => Vhdl,
"yaml" => Yaml,
"zig" => Zig,
_ => continue,
})
}
None

@ -681,9 +681,7 @@ impl MatchKind {
pub(crate) fn is_novel(&self) -> bool {
matches!(
self,
Self::Novel { .. }
| Self::NovelWord { .. }
| Self::UnchangedPartOfNovelItem { .. }
Self::Novel { .. } | Self::NovelWord { .. } | Self::UnchangedPartOfNovelItem { .. }
)
}
}