[Mergeview] - How to get the added/removed counts from mergeview

Hi, I am using “@codemirror/merge”: “^0.1.3” which has changed details from the chunks. is there any property available for getting the added/removed counts? as I checked library exports I don’t find anything that gives info on added/removed counts of changes?

Counts of what, exactly? You could sum the length of the change arrays from the chunks to get the number of individual changes, if that’s what you are looking for.

1 Like

yup, we can get the total changes from the sum of the changes which is inside chunks.

but I wanted the counts added and removed over the previous version.

changes array just provides the position range that changes occurred which I can use to get the total changes. but I want to get the added and removed counts. am not able to differentiate the added/removed counts from the changed data.

@marijn any suggestion on getting the counts of added/removed over left side code or previous version in the merge view

I’m not clear on what you mean by added/removed counts.

@marijn
let’s say I committed a code to GitHub today. tomorrow am coming back and making some changes on some files and pushing the code. now GitHub shows the total changed files and added removed counts. I wanted to get the counts like this from the MergeView. because merge view we can as Diff view also. now am showing a Diff view like the image attached below.
if am using Merge view as just Diff view like the image shown below. is there a way to get that counts like changing chuncks array?. I Hope you are getting question

I see, ‘lines’ appears to be the word you kept omitting from all your sentences that could have clarified this. The data structure doesn’t explicitly store those, but I think that if you resolve the lines at the start and end of each chunk and take their difference in number, accounting for the fact that a non-empty chunk at the end of the document has a to position that can’t be resoled, you should get the numbers you’re looking for.

so there is no direct way to get that count which I am expecting. I feel it would be great if the component has the like read-only property to get this count. since it’s a common use case in the merge/diff view.
I think diff algorithm which returns those details. and can be exported as read-only if possible. .