Word-diff comments
Problem to solve
#325856 introduces the ability to view changes in word-diff mode, which is much more efficient for content such as prose because it shows changes within the content instead of showing entire lines that are added/removed or showing changes side-by-side. Inserting comments however does not map 1-to-1 with other modes, as what in inline mode is attributable to 3 lines, may be attributable to only 1 line in word-diff mode, which makes handling comments tricker.
Vasilii illustrates the problem here #325856 (comment 563421531)
While working on word-diff mode, I noticed that the order of diff lines generated by git diff --word-diff
can be different from the regular git diff
mode. I expect that creating a consistent line mapping between two modes can become a problem.
git diff
-class MyClass # 1
- def init # 2
- change = '1' # 3
- end # 4
+# Add a comment # 5
+# And another one # 6
+class MyKlass # 7
+ df initialization # 8
+ new_change = '2' # 9
+ # 10
git diff --word-diff --word-diff-regex=.
10 lines of regular diff
are presented with 5 lines in word-diff
mode.
The last line {+new_+}change = '[-1-]{+2+}'[- end-]
consists of content from removed lines 3, 4 and the new line 9.
- When the user comments on this line in the
word-diff
mode, then where should we display the comment in theregular diff
mode (3, 4 or 9)? - And vice versa, imagine there are comments attached to lines 3, 4 and 9 in the
regular diff
mode. How should we present them in theword-diff
mode? Should they be attached to the same line there? What if comments belong to thread? Will we have 3 threads grouped together?
I expect other challenges with line mapping between modes too. To be on the safe side, I would suggest going with the limitation approach suggested by @pedroms. It will allow us to release word-diff mode even if we face difficulties with commenting or line detection. After that, we can investigate and introduce comments' support to word-diff
mode as a follow-up issue.
Proposal
- If there are only additions, attach to line where addition exists
- If there are only removals, attach to the line where the removal was done
- If there are both, attach to the line where the addition was made
- If line has not changed at all, comment behaves the same as it does today for inline view
- Additions and removals to multiple lines TBD
This page may contain information related to upcoming products, features and functionality. It is important to note that the information presented is for informational purposes only, so please do not rely on the information for purchasing or planning purposes. Just like with all projects, the items mentioned on the page are subject to change or delay, and the development, release, and timing of any products, features, or functionality remain at the sole discretion of GitLab Inc.