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

align gutter png icon position with line number #5611

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

InspiredGuy
Copy link
Contributor

@InspiredGuy InspiredGuy commented Jul 13, 2024

Issue #, if available:
#5380

Description of changes:
Moving the background which sets the gutter png icons from .ace_gutter-cell.ace_error to .ace_gutter-cell.ace_error .ace_icon. It's the same container used for displaying annotations in folded block.

Initially I've tested a naive fix for this by moving the background position to top instead of center (same positioning would be achived with background-position: 2px -1px; instead of background-position: 2px center;). It looked OK on default font size, but with font size changing it did not keep up the alignment with line numbers (see screenshot below). Solution implemented in this PR keeps the icons aligned with line numbers regardless of font size.
image

To test this open https://raw.githack.com/ajaxorg/ace/fix-gutter-icon-position/kitchen-sink.html, set the soft wrap to 40 and type long enough and wrong enough to see annotations in a multiline row,

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Pull Request Checklist:

Copy link

codecov bot commented Jul 13, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.89%. Comparing base (b7495e1) to head (588fe48).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5611   +/-   ##
=======================================
  Coverage   86.89%   86.89%           
=======================================
  Files         594      594           
  Lines       43143    43158   +15     
  Branches     7150     7150           
=======================================
+ Hits        37489    37504   +15     
  Misses       5654     5654           
Flag Coverage Δ
unittests 86.89% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@InspiredGuy
Copy link
Contributor Author

@nightwing @akoreman let me know if you have any concerns about moving the background to another element. I've checked the codebase but it doesn't seem the target element is used for anything except for showing errors in folded block (which is not affected by this change).

@akoreman
Copy link
Contributor

I think the one concern would be what would happen if people currently have a custom theme theme set the background image to .ace_gutter-cell.ace_error? Would this change break them by displaying both background images on top of each other?

On the other hand, this is a bullet we might need to bite at some point and accept that for these rare use cases people will have to make a change, but in that case, would it be better to just fully deprecate the PNG icons and fully go for the new SVG ones?

@InspiredGuy
Copy link
Contributor Author

I think the one concern would be what would happen if people currently have a custom theme theme set the background image to .ace_gutter-cell.ace_error? Would this change break them by displaying both background images on top of each other?

Yeah, it's not like their app won't run but this scenario you've described is certainly possible. It might be even worse since it will be implicit.

On the other hand, this is a bullet we might need to bite at some point and accept that for these rare use cases people will have to make a change, but in that case, would it be better to just fully deprecate the PNG icons and fully go for the new SVG ones?

This would be breaking on the interface level as we'd need to deal with the API property we have. If we remove it it's kind of a breaking change, and if we just ignore the passed value it's also kind of a breaking change. It might be wise to save such moves until the next major version :)

@InspiredGuy
Copy link
Contributor Author

I've updated the PR to calculate the background position based on the font size and icon size in the currently used container. Value for line height is 1.2, which is the same as normal (see docs). Icon size is 16x16 implicitly. It can be tested here - https://raw.githack.com/ajaxorg/ace/fix-gutter-icon-position/kitchen-sink.html

Not the prettiest solution, and if we think it's too risky I'm OK to discard it completely, this issue is not super important.

FYI @akoreman

@InspiredGuy
Copy link
Contributor Author

@nightwing I've checked the codebase and it seems like css variables are not used anywhere yet. Is there a reason for this? They seem well-supported across browsers.

@InspiredGuy InspiredGuy changed the title move default gutter png icons rendering to .ace_icon align gutter png icon position with line number Jul 14, 2024
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.

2 participants