Expand description
Prefer contiguous novel nodes on the same line.
A slider takes the following form:
Old:
A B
C D
New:
A B
A B
C D
It would be correct, but ugly, to show the following diff:
A +B+
+A+ B
C D
This module fixes these cases. It identifies situations where we
can change which item is marked as novel (e.g. either B
in the
example above) whilst still showing a valid, minimal diff.
Functions
- Return the distance between two syntax nodes, as a tuple of number of lines and number of columns.
- Correct sliders in middle insertions.
- When we see code of the form
old1(novel(old2()))
, prefer treating the inner delimiter as novel, sonovel(...)
in this example. - When we see code of the form
(old-1 (novel (old-2)))
, prefer treating the outer delimiter as novel, so(novel ...)
in this example. - For every sequence of novel nodes, if it’s a potential slider, change which nodes are marked as novel if it produces a sequence of nodes that are closer together.
- Return the start and end indexes of sequences of novel nodes that occur after unchanged nodes.
- Return the start and end indexes of sequences of novel nodes that occur before unchanged nodes.
- Should nester slider correction prefer the inner or outer delimiter?
- Given a nested list where the root delimiters are novel but the inner list’s delimiters are unchanged, mark the root list as unchanged instead.
- Given a nested list where the root delimiters are unchanged but the inner list’s delimiters are novel, mark the inner list as unchanged instead.
- If the next node is unchanged, matches the beginning of the region, and has a smaller text distance, mark it as novel.
- If the previous node is unchanged, matches the end of the region, and has a smaller text distance, mark it as novel.
- Find the unchanged descendants of
nodes
. - Nested sliders require a single unchanged descendant whose delimiters we can slide.