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
Rainbow parentheses feature #7027
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.
Very minor tweaks requested, and a few additional generic questions:
- guessing you already did, but make sure the themes unit-tests pass
- have you sanity tested in IE11?
- what happens if someone has previously imported a custom theme, then upgrades and turns on rainbow parentheses; just curious how that works in general when we add new css rules to the themes
/* | ||
* rainbow_paren_highlight_rules.js | ||
* | ||
* Copyright (C) 2009-20 by RStudio, PBC |
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.
Switch to our new "current-year only" format.
@@ -77,6 +77,7 @@ public EditingPreferencesPane(UserPrefs prefs, | |||
"When enabled, the indentation for documents not part of an RStudio project " + | |||
"will be automatically detected.")); | |||
editingPanel.add(checkboxPref("Insert matching parens/quotes", prefs_.insertMatching())); | |||
editingPanel.add(checkboxPref("Rainbow parentheses", prefs_.rainbowParentheses())); |
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.
Does everything in this pane still fit (vertically)? Noticed this pane is getting very full. I ran into a problem adding a checkbox to the Code / Display pane in #7030 and had to remove some other spacing or it was slightly clipped at the bottom
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.
It does, there's still room for like...one more checkbox. It's definitely cramped though. We are in the situation where we want to start thinking about a different format for our options panel.
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.
Nicely done! Overall this LGTM -- the one thing that I think is missing is one bit of code where we check this explicit type for parentheses; e.g. here:
I think that code needs to be changed to accommodate the new type.
Also echoing Gary's question here:
I think we need to still include the default |
Unfortunately in the themes |
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.
LGTM! Excited to see this in action.
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 do think it's going to be a problem that this feature won't work with old custom themes. Here is a proposal for resolving the issue:
- Make the theme CSS rules for the colors more specific; e.g., rather than
.ace_paren_color_0
, the theme could specifydiv .ace_editor .ace_paren_color_0
. - Define a default set of dark/light CSS colors for parens and include them in our root style sheet, themes.css (i.e.
.ace_paren_color_0
,.editor_dark .ace_paren_color_0
).
This way the themes can customize the colors as needed, but if the theme fails to provide the colors we will still get nice defaults. What do you think?
@@ -515,6 +515,11 @@ | |||
"title": "Highlight R function calls", | |||
"description": "Whether to highlight R function calls in the code editor." | |||
}, | |||
"rainbow_parentheses": { | |||
"type": "boolean", | |||
"default": false, |
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.
Add a title
to this (and regenerate prefs) so it can be set from the Command palette.
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.
(note you'll probably have to merge master into your branch to get this capability)
That solution sounds good. I wish we could just remove |
If you go the route of adding default styles, it looks like you could even forgo the addition of adding CSS rules to individual themes, since we just have one rainbow set for dark themes and another for light themes (easily scoped with |
Ok this should be good to go now! |
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.
LGTM!
@kevinushey it this looks good to you it's ready to go! |
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.
LGTM!
🎉 |
Colorize matching parentheses, braces, and brackets in a series of colors. This is customizable in the theme CSS. It can also be turned on/off dynamically per document through the
Code -> Rainbow parentheses
option.Example in light and dark themes:
Closes #1888