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

Additional ways to format #21

Open
nickserv opened this issue Oct 11, 2019 · 3 comments
Open

Additional ways to format #21

nickserv opened this issue Oct 11, 2019 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed
Milestone

Comments

@nickserv
Copy link
Member

nickserv commented Oct 11, 2019

These are some ideas based on what I think is useful though I'm not sure we'd want all of them:

  • Keyboard shortcut (prettier-js-extension uses Ctrl + Shift + F)
  • Button action (clicking on the extension icon in Chrome's extension toolbar)
  • Context menu
  • Automatic formatting (could work like the VSCode extension and allow auto formatting on any supported file, possible with a debounce/throttle if we hit performance bottlenecks)

Note: These could make #20 easier to implement as we wouldn't have to worry about placing a button in an unknown UI, which could break stuff or look ugly.

@nickserv nickserv changed the title Additional ways to execute formatting Additional ways to format Oct 11, 2019
@kaicataldo kaicataldo added the enhancement New feature or request label Oct 15, 2019
@kaicataldo
Copy link
Member

The only one I have reservations about is the automatic formatting. Otherwise, I like this idea a lot! I also think it would be nice to add a feature where, if text is selected, it will only format that text.

@kaicataldo kaicataldo added the help wanted Extra attention is needed label Oct 16, 2019
@nickserv
Copy link
Member Author

nickserv commented Oct 17, 2019

The only one I have reservations about is the automatic formatting.

Out of curiosity, what don't you like about it? How would you feel about adding it with a toggle that's off by default?

I also think it would be nice to add a feature where, if text is selected, it will only format that text.

As far as I'm aware Prettier requires formatted text to be valid as an entire file, so this would mean that only some selections could be formatted properly. Personally I think it's easier to only allow formatting entire inputs, since it's closer to Prettier's built in functionality. Otherwise we would have to explain to the user why selections are invalid and implement extra error handling.

@nickserv nickserv added this to the MVP milestone Oct 17, 2019
@kaicataldo
Copy link
Member

Out of curiosity, what don't you like about it? How would you feel about adding it with a toggle that's off by default?

Having a toggle sounds good! I don't think it's a good idea to modify text as users are typing, since characters can move and make it really unwieldy.

As far as I'm aware Prettier requires formatted text to be valid as an entire file, so this would mean that only some selections could be formatted properly. Personally I think it's easier to only allow formatting entire inputs, since it's closer to Prettier's built in functionality. Otherwise we would have to explain to the user why selections are invalid and implement extra error handling.

That's right. What I like about this functionality is that blocks of code that aren't in markdown can be formatted. That being said, I don't think this should be a high priority feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants