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
Playground: Add support for rangeStart and rangeEnd #4216
Conversation
Looks cool 👍 (live preview) |
And full for reference, here is me recreating the issue I outline here (#3789 (comment)) in the running local version of this PR branch: |
website/static/playground.js
Outdated
@@ -194,6 +196,9 @@ window.onload = function() { | |||
|
|||
function setOptions(options) { | |||
OPTIONS.forEach(function(option) { | |||
if (option === undefined) { | |||
return; | |||
} |
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.
What's this check for? We're iterating over an array of known values, so there shouldn't be any undefined values here
website/pages/playground/index.html
Outdated
@@ -95,6 +95,8 @@ <h1>Prettier <span id="version"></span></h1> | |||
<label>--print-width <input type="number" value="80" min="0" id="printWidth"></label> | |||
<label>--tab-width <input type="number" min="0" value="2" id="tabWidth"></label> | |||
<label><input type="checkbox" id="useTabs"> --use-tabs</label> | |||
<label>--range-start <input type="number" min="0" id="rangeStart"></label> | |||
<label>--range-end <input type="number" min="0" id="rangeEnd"></label> |
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 guess these should belong to Special
category.
Just an idea: What if you could set the range by selecting a piece of text somehow? Probably another PR though. Possibly not even useful. |
I like that idea. If that proves difficult, we could render the start/end markers as lines behind the text. |
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! I love the idea of being able to directly select the range to be formatted, but think we should save it for a separate change. No opinion on whether these new options belong in the Global
or the Special
category.
@JamesHenry Let's do it 👍 |
Oh, if you've already got it working, by all means include it! That would make it much easier to know what the range actually is and to get it right. FWIW, I'm also curious about #4216 (comment) |
8e5a485
to
72e159d
Compare
Same example from above but with all of the new updates: Ready for final review! |
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.
Really cool! 👍
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/addon/edit/closebrackets.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/addon/comment/comment.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/addon/wrap/hardwrap.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.26.0/keymap/sublime.js"></script> |
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 update all of these in website/static/service-worker.js as well
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.
Done
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.
🎉
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.
This looks great! If anything, I'd suggest making the highlight color a little easier to see (light yellow on white doesn't have much contrast), but I think this can be landed regardless.
I was delighted to see that this appears to be very easy to add and would allow users to more easily reproduce and report issues such as:
...etc...