3 ms·
> when you change 1 line of code, the diff may or may not show it as having changed one line of code. Can you offer an example where an editor is used to chang
by hunter2_ 3y ago
> when you change 1 line of code, the diff may or may not show it as having changed one line of code.
Can you offer an example where an editor is used to change one line of code, and a resulting diff leads the user to believe that the number of changed lines is not one?
I don't think people interpret an adjacent opposing pair (one line removed, immediately followed by one line added) as not show[ing] it as having changed one line of code.
- jstanley 3y agoA diff like this is perfectly valid: -foo -bar -baz +foo +bar Although I don't know any tool which would actually generate such a diff.
- hunter2_ 3y agoOh! I was keeping my thoughts scoped to the output of existing tools. Beyond that doesn't seem worth considering in this particular context.
- seba_dos1 3y agoThe existing tools already let you choose the algorithm used to generate the diff, so it's not a big stretch to imagine an algorithm that may do just this. It doesn't make much sense for such 1 line example (although it could if you had, say, an algorithm that considers whole paragraphs, or blocks in some programming language, rather than lines - could be useful for line art perhaps), but with more complex changes there won't be a single "optimal" representation, especially when what's "optimal" depends on what you want to optimize for.