diff options
author | Dan Davison <dandavison7@gmail.com> | 2020-02-06 13:40:45 -0600 |
---|---|---|
committer | Dan Davison <dandavison7@gmail.com> | 2020-02-06 13:58:59 -0600 |
commit | f6d4d333d5c06f66643622206f384a3410c14c61 (patch) | |
tree | 2ed11a16aa7c5b5dd3eec8a1bb4aac2196f875c8 | |
parent | c29dcf280ee1d2d00bcfce776ba857fe7cd7d189 (diff) |
Tighten up state machine parser. Fixes #89
Prior to this commit, in a language in which -- at the beginning of a
line is valid (e.g. a Haskell or SQL comment), then removal of such a
line was being confused with the --- marker used in unified/git diff
to introduce the file paths.
-rw-r--r-- | src/delta.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/delta.rs b/src/delta.rs index 527e5885..1425bf15 100644 --- a/src/delta.rs +++ b/src/delta.rs @@ -86,7 +86,10 @@ where painter.paint_buffered_lines(); state = State::FileMeta; painter.set_syntax(parse::get_file_extension_from_diff_line(&line)); - } else if (line.starts_with("--- ") || line.starts_with("rename from ")) + } else if (state == State::FileMeta || source == Source::DiffUnified) + // FIXME: For unified diff input, removal ("-") of a line starting with "--" (e.g. a + // Haskell or SQL comment) will be confused with the "---" file metadata marker. + && (line.starts_with("--- ") || line.starts_with("rename from ")) && config.opt.file_style != cli::SectionStyle::Plain { if source == Source::DiffUnified { |