You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sometimes difftastic will parse a file incorrectly either due to an error in the parser, an error in the file itself or a complicated situation not yet handled by the parsers (e.g. helm templates, which are kind-of yaml files with embedded go-template, see #267 and #377). In those cases it would be helpful if the user could force difftastic to use the default text parsing instead of showing "No syntatic changes."
I envision something like: difft --language default or difft --default-parser
I'm willing to make a PR but I don't know rust and don't know where should I start 🙈
(1) One idea would be to treat the default text parser the same as the other parsers. I would add a default language in the languages enum and then instead of matching to None we would match to this default. For example here:
But that would change the design choice of using None to fallback to text parsing. Another alternative to this idea would be to re-design the whole line_parser to fit the vendor parsers format. I have absolutely no idea how I would do that 😅
(2) Another idea would be adding a --default-parser flag and then ignore language_override. For example here:
let language = language_override.or_else(|| guess(guess_path, guess_src));
would become something like:
let language = if default_parser {None;}else{
language_override.or_else(|| guess(path,&src));}
The important point here is side-stepping the guess function.
I tend to prefer Option (2) because it seems less intrusive to me, but it still adds another top level flag which could maybe be covered by an already existing flag. I'll try to implement that one but am very welcome to feedback, specially if I'm tackling this issue completely wrong!
The text was updated successfully, but these errors were encountered:
mparada
pushed a commit
to mparada/difftastic
that referenced
this issue
Dec 7, 2022
Sometimes difftastic will parse a file incorrectly either due to an error in the parser, an error in the file itself or a complicated situation not yet handled by the parsers (e.g. helm templates, which are kind-of yaml files with embedded go-template, see #267 and #377). In those cases it would be helpful if the user could force difftastic to use the default text parsing instead of showing "No syntatic changes."
I envision something like:
difft --language default
ordifft --default-parser
I'm willing to make a PR but I don't know rust and don't know where should I start 🙈
(1) One idea would be to treat the default text parser the same as the other parsers. I would add a
default
language in the languages enum and then instead of matching toNone
we would match to thisdefault
. For example here:But that would change the design choice of using
None
to fallback to text parsing. Another alternative to this idea would be to re-design the wholeline_parser
to fit the vendor parsers format. I have absolutely no idea how I would do that 😅(2) Another idea would be adding a
--default-parser
flag and then ignorelanguage_override
. For example here:would become something like:
The important point here is side-stepping the
guess
function.I tend to prefer Option (2) because it seems less intrusive to me, but it still adds another top level flag which could maybe be covered by an already existing flag. I'll try to implement that one but am very welcome to feedback, specially if I'm tackling this issue completely wrong!
The text was updated successfully, but these errors were encountered: