-
Notifications
You must be signed in to change notification settings - Fork 7.6k
Sync code hint font size with code view font size #13091
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would like to see at least the documentation fixed.
src/view/ViewCommandHandlers.js
Outdated
@@ -122,10 +128,10 @@ define(function (require, exports, module) { | |||
* @param {string} value Is the value of the style | |||
* @param {boolean} important Is a flag to make the style property !important |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cssRule
and cssText
aren't documented.
src/view/ViewCommandHandlers.js
Outdated
cssRule = cssRule || ".CodeMirror"; | ||
var $style = $("<style type='text/css'></style>").attr("id", propertyID); | ||
var styleStr = StringUtils.format("{0}: {1}{2}", name, value, important ? " !important" : ""); | ||
var styleStr = cssText || StringUtils.format("{0}: {1} {2}", name, value, important ? " !important" : ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you can remove the space between this two parameters {1} {2}
.
src/view/ViewCommandHandlers.js
Outdated
|
||
/** | ||
* @private | ||
* Adds a new embeded style top sync code-hint font size with codeview font size |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fontSize
is not documented
src/view/ViewCommandHandlers.js
Outdated
var styleStr = ""; | ||
styleStr = styleStr + StringUtils.format("{0}: {1} {2};", "font-size", fontSize, " !important"); | ||
styleStr = styleStr + StringUtils.format("{0}: {1} {2};", "line-height", (parseInt(fontSize, 10) + 2) + fontSize.replace(parseInt(fontSize, 10), ""), " !important"); | ||
_addDynamicProperty(DYNAMIC_CODEHINT_FONT_STYLE_ID, "font-size", fontSize, true, ".codehint-menu .dropdown-menu li a", styleStr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need to pass the values font-size
, fontSize
and true
but they aren't actually used.
Perhaps it's personal style but it doesn't seems good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think function _addDynamicProperty(propertyID, options)
would make more sense (where options would be an object of { name, value, important, cssRule, cssText }
etc.)
Thanks a lot @ficristo for the quick review 👍 I will update the PR soon. |
Question around the approach. Adding the a method specific for code hints seems reasonable, but I am not sure how that will scale if we had to add more methods for different parts of the UI. Is there a way we can leverage CSS for the fonts size/type? |
@MiguelCastillo Good point to consider 👍. |
I'd say that while @MiguelCastillo 's point is valid, we should not get into the habit of stacking feature on top of feature in PRs which makes them not only very large but also increases the time which they take to merge, sometimes are these even never merged as authors get discouraged. So if @swmitra 's PR works and solves the problem it was meant to solve (without introducing new ones), we should merge it and open further suggestions as separate issues. |
@ficristo We no longer use that icon in JS code hints. I am a bit confused as I don't see those icons in JS code hints, Can you please confirm once more? |
@swmitra you are right. After I had disabled my extensions I don't see it anymore. |
@MiguelCastillo Can you please check the implementation now? I just tried to make it extensible by using a less template. |
yup i am checking now. BTW - thank you for clarifying the use case. It definitely helped me understand the scope of what we are accomplishing. I am happy with what we got here :) |
} | ||
|
||
.codehint-menu .dropdown-menu { | ||
max-height: @maxvisibleitems * @lineheight !important; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does line height affect this when the fontsize is define in px
vs em
?
I like what you have done here! very interesting! I just had a question regarding the max-height value and how it is affected when font size is specified with different units. |
@MiguelCastillo I had made core template calculations unit agnostic. Also I had to introduce an additional step to convert only em to px. Rest all units like pt, rem and px works well with this implementation. Please check the code and try out the implementation and let me know if see any issues. |
@swmitra yeah - this is good to merge for me. I am not sure if there are any TODOs pending, are there? |
@ficristo Can you please have a look now? |
@MiguelCastillo review is more than enough for me. |
Is there any way to revert this? It feels like I can see way fewer hints than I used to, and any code hints that include documentation look misaligned, so I'd rather go back to the default font size & code hint area height. |
This PR enhances Brackets user experience by syncing the code hint font-size with code view font size. This was a problem in high dpi monitors ( WQHD and above ), where code hints were not readable with the current font-size. With this PR , when user changes code view font size, code hint font size also gets changed accordingly.
Without this PR, code hints are rendered as -
With the changes in PR -