Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: changedelete symbol with linematch enabled #954

Merged
merged 1 commit into from Mar 12, 2024

Conversation

clktmr
Copy link
Contributor

@clktmr clktmr commented Mar 11, 2024

Since linematch will report a changed line following deleted lines as multiple hunks on a single line, it will only show the changed sign and will drop the deleted sign. To fix this check for overlapping hunks and mark the change hunk as changedelete.

Fixes #701 in part

-- To stop the sign column width changing too much, if there are signs to be
-- added but none of them are visible in the window, then make sure to add at
-- least one sign. Only do this on the first call after an update when we all
-- the signs have been cleared.
if clear and i == 1 then
signs:add(bufnr, gs_hunks.calc_signs(hunk, hunk.added.start, hunk.added.start, untracked))
signs:add(bufnr, gs_hunks.calc_signs(hunk, hunk.added.start, hunk.added.start, untracked, changedelete))
Copy link
Owner

Choose a reason for hiding this comment

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

Would it be better to pass in next?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It felt consistent this way because untracked is also passed in. On the other hand it would put the actual sign calculation in calc_signs. Give me a moment, I'll change it

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@clktmr clktmr force-pushed the main branch 2 times, most recently from 93394bb to c8c854b Compare March 11, 2024 12:57
Since linematch will report a changed line following deleted lines as
multiple hunks on a single line, it will only show the `changed` sign
and will drop the `deleted` sign.  To fix this check for overlapping
hunks and mark the change hunk as changedelete.
@clktmr
Copy link
Contributor Author

clktmr commented Mar 11, 2024

BTW I think the default sign for 'changedelete' is a bit unfortunate. For me using a blend of change and delete is more intuitive. Are you open to change the default icons? I would recommend

delete = { text = ' ▁' },
topdelete = { text = ' ▔' },
changedelete = { text = '┃▁' },

This puts delete and topdelete on the second char of the sign, and changedelete is just a combination of both.

@lewis6991 lewis6991 merged commit 41dc075 into lewis6991:main Mar 12, 2024
5 of 6 checks passed
@lewis6991
Copy link
Owner

For me using a blend of change and delete is more intuitive. Are you open to change the default icons? I would recommend

Ideally, every hunk should get it's own sign. For changedelete, I think it would be better to use change and topdelete.

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.

some linematch hunks need topdelete
2 participants