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

git-changebar: Re-set first visible line after Scintilla size request #1280

Merged
merged 1 commit into from
Oct 13, 2023

Conversation

techee
Copy link
Member

@techee techee commented Oct 12, 2023

After updating to Scintilla 5.3.7 the Scintilla popup with the diff against git shows the wrong number.

It seems that gtk_widget_set_size_request() scrolls Scintilla view so despite it was set previously, it isn't set correctly after this call and has to be re-set.

Note that the call to SCI_SETFIRSTVISIBLELINE has to stay at the original location too, otherwise subsequent calculation using SCI_POINTXFROMPOSITION doesn't work because the line may not be visible.

@b4n Does this look OK to you? Maybe there's a better way to fix this problem so take this only as a hint where the problem is.

Fixes #1279

@techee techee added this to the 1.39.0/2.0.0 milestone Oct 12, 2023
@@ -878,6 +878,10 @@ get_widget_for_buf_range (GeanyDocument *doc,
MIN (width + 2, alloc.width),
MIN (height + 1, alloc.height));

/* Size request seems to scroll Scintilla view so we have to re-set visible lines again */
scintilla_send_message (sci, SCI_SETENDATLASTLINE, 0, 0);
Copy link
Member

Choose a reason for hiding this comment

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

any reason to re-set ENDATLASTLINE? I don't see it being needed on my end, did you see an issue without it?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, it doesn't seem to be necessary, I just copied the two lines above. Repushed without this line.

Copy link
Member

@b4n b4n left a comment

Choose a reason for hiding this comment

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

Thanks a lot for debugging this up to that point! I somehow didn't notice this until fairly recently, and was puzzled (and frightened) at what it could be, yet didn't have time to dig in. And now I see you did, yay!

I don't see a problem re-asking for the line; although at some point I'll try and understand what changed in Scintilla that would lead to this.

After updating to Scintilla 5.3.7 the Scintilla popup with the diff
against git shows the wrong number.

It seems that gtk_widget_set_size_request() scrolls Scintilla view so
despite it was set previously, it isn't set correctly after this call
and has to be re-set.

Note that the call to SCI_SETFIRSTVISIBLELINE has to stay at the original
location too, otherwise subsequent calculation using SCI_POINTXFROMPOSITION
doesn't work because the line may not be visible.
Copy link
Member

@b4n b4n left a comment

Choose a reason for hiding this comment

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

LGTM.

I don't understand what's actually going on, especially as from my tests it seems to work alright without this for lines <= 182 for me (yes, that feels random). Changes on later lines are stuck starting at line 182…

Anyway, this works and shouldn't cause any more problems.

@techee
Copy link
Member Author

techee commented Oct 13, 2023

Thanks a lot for debugging this up to that point!

Essential plugin, life would be unbearable without it :-).

I somehow didn't notice this until fairly recently, and was puzzled (and frightened) at what it could be, yet didn't have time to dig in.

I was worried it could be some "unsolvable" conflict with the changebar that is now part of Scintilla. But then all the printfs I added seemed to return the right value and then I displayed line numbers in the Scintilla popup and it was clear it wasn't set correctly.

I don't see a problem re-asking for the line; although at some point I'll try and understand what changed in Scintilla that would lead to this.

Yeah, who knows.

It's actually kind of surprising that it works now because SCI_POINTXFROMPOSITION didn't work when I removed SCI_SETFIRSTVISIBLELINE in front of the size request and moved it behind - so SCI_POINTXFROMPOSITION works only for the displayed editor area but in this case it isn't displayed yet and sci has some who-knows-what size before the size request. But I don't know how this could be fixed.

Anyway, good, it works now, the world seems to be saved for a while :-)

@b4n
Copy link
Member

b4n commented Oct 13, 2023

It's actually kind of surprising that it works now because SCI_POINTXFROMPOSITION didn't work when I removed SCI_SETFIRSTVISIBLELINE in front of the size request and moved it behind - so SCI_POINTXFROMPOSITION works only for the displayed editor area but in this case it isn't displayed yet and sci has some who-knows-what size before the size request. But I don't know how this could be fixed.

Ugh… yeah, maybe someday I'll have to figure that out, because it doesn't seem very safe indeed. 🤞

Anyway, good, it works now, the world seems to be saved for a while :-)

Thanks! 🕵️

@b4n b4n merged commit 74202cd into geany:master Oct 13, 2023
2 checks passed
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.

Change popup not working in git-changebar after updating to Scintilla to 5.3.7
2 participants