Compute token-level changes between two lines. This is the core of the token-level diff - it compares the tokens of two lines and produces a sequence of token changes.
(
before: &SemanticLine<'a>,
after: &SemanticLine<'a>,
config: &WordDiffConfig,
)
| 272 | /// This is the core of the token-level diff - it compares the tokens |
| 273 | /// of two lines and produces a sequence of token changes. |
| 274 | pub(super) fn compute_token_changes<'a>( |
| 275 | before: &SemanticLine<'a>, |
| 276 | after: &SemanticLine<'a>, |
| 277 | config: &WordDiffConfig, |
| 278 | ) -> Vec<TokenChange<'a>> { |
| 279 | // Use word diff to find token-level changes |
| 280 | let word_result = word_diff_with_config( |
| 281 | before.content_without_newline(), |
| 282 | after.content_without_newline(), |
| 283 | config, |
| 284 | ); |
| 285 | |
| 286 | convert_word_diff_to_token_changes(&word_result, before, after) |
| 287 | } |
| 288 | |
| 289 | /// Convert word diff operations to token changes. |
| 290 | pub(super) fn convert_word_diff_to_token_changes<'a>( |