Skip to content

feat: character diffs#38

Open
KnorpelSenf wants to merge 9 commits intopascalkuthe:masterfrom
KnorpelSenf:char-diff
Open

feat: character diffs#38
KnorpelSenf wants to merge 9 commits intopascalkuthe:masterfrom
KnorpelSenf:char-diff

Conversation

@KnorpelSenf
Copy link
Contributor

@KnorpelSenf KnorpelSenf commented Nov 8, 2025

Builds on top of the changes in #33 in order to add support for character diffs. Should be reviewed only after #33 is merged. The diff is here: KnorpelSenf/imara-diff@word-diff...KnorpelSenf:imara-diff:char-diff

While a character diff can technically be performed directly on a line diff, this implementation supports performing a character diff on top of a word diff, too. That way, one can:

  1. perform a line diff
  2. for each line hunk, perform a word diff
  3. for each word hunk, perform a char diff

}

fn estimate_tokens(&self) -> u32 {
self.as_str().len() as u32
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There might be a better heuristic than this. Perhaps we should do

Suggested change
self.as_str().len() as u32
256.min(self.as_str().len() as u32)

instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant