Skip to content

Commit

Permalink
Tighten up state machine parser. Fixes dandavison#89
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
dandavison committed Feb 6, 2020
1 parent c29dcf2 commit f6d4d33
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit f6d4d33

Please sign in to comment.