• Kissaki@programming.dev
    link
    fedilink
    English
    arrow-up
    2
    ·
    edit-2
    19 days ago

    "" to '' … There is nothing to highlight for SemanticDiff.

    Really? I definitely want to see that. I want to be deliberate about my code. I am not only targeting compiled code. I am also targeting developers through maintainable code.


    I’m surprised they did not list an alternative that would be my preference: Highlight the entire string. The f prefix changes the entire text value type. I would like the `f´ to be highlighted strongly, and string it changes the interpretation of weakly, and the placeholder variable more strongly again.

    • DarkPlayer@lemmy.worldOP
      link
      fedilink
      arrow-up
      0
      ·
      19 days ago

      Many code formatters decide whether to use " or ' based on some configuration and whether the default one would require escaping. So if you are using such a code formatter, this is no longer a deliberate choice unless you explicitly override the behavior with annotations.

      I am not sure whether your solution of using a less intense color for the unchanged part of the string would make it clearer. It is just more similar to other diff tools that highlight the whole line with a less intense color if it contains changes.

      • Bogasse@lemmy.ml
        link
        fedilink
        arrow-up
        0
        ·
        18 days ago

        Then with a code formatter you definitely want to show this change. In a normal usage the code formatter should ensure that this kind of diff can’t happen, then it’s useful to see if it was not used during a code review.

        • brian@programming.dev
          link
          fedilink
          arrow-up
          2
          ·
          16 days ago

          just stick a verification task in ci. if I have to check if the format matches the standard in a code review instead of reviewing meaningful things my time is being wasted

          • Bogasse@lemmy.ml
            link
            fedilink
            arrow-up
            1
            ·
            16 days ago

            Yeah exactly, I’m not it was clear that it was what I meant by “the formatter should ensure …”

  • driving_crooner@lemmy.eco.br
    link
    fedilink
    arrow-up
    2
    ·
    18 days ago

    I like the way azure dev-ops do it, they highlight the entire line with a soft color and the changes with a harder one. Isn’t not semantic afaik.

  • drathvedro@lemm.ee
    link
    fedilink
    arrow-up
    0
    arrow-down
    1
    ·
    edit-2
    18 days ago

    I don’t see what’s the point of the second one if the syntax highlight, even in the first example, already shows a changed role.

    A more realistic solution for the example code would be to setup a linter in the pipeline, and if one letter variables and/or template literals are detected, depending on how nice you are, reject the commit, or send an email requesting the author to be beaten up with a crowbar to the teamlead, and a copy, parsed by chatGPT for formality and politeness, to the HR.

    • brian@programming.dev
      link
      fedilink
      arrow-up
      2
      ·
      16 days ago

      that’s not a one letter template literal, that’s built in python syntax. it only has combinations of u r and f and no user defined option. f makes it templated