-
Notifications
You must be signed in to change notification settings - Fork 25
Added support for shift+tab to decrease indents. #36
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
base: master
Are you sure you want to change the base?
Added support for shift+tab to decrease indents. #36
Conversation
How does this compare to #30? |
It works more like @newsiberian mentioned regarding WebStorm's functionality.
This adds indentation decrease, which is a line-based action. That meansit will remove indentation from the start of the line regardless of the cursor's position. If there is no indentation at the start of the line, it will ignore the request to decrease indentation. For my needs, and this seems to be reflected in @newsiberian's comment above, there should separate functionality for 'backspace' (remove from the cursor's position) and 'shift+tab' (remove the line's indentation). If we wanted, to add more flexibility, we could add an optional parameter in |
I see, that makes sense! This breaks for me on any code block that has > 1 line of code, see this recording: https://www.dropbox.com/s/qspu16vnb2zrrjr/remove-tab-bug.mov?dl=0 Mind fixing that and adding some tests verifying both that case and the "no indentation at start" case work as expected? Thanks! |
Yeah, no problem, thanks for catching that! |
When handling tab decrease, we shouldn't assume the user wants to remove all indentation at the start of the line. With a new 'default tab' setting, we can define the tab setting (number of spaces) for the editor. Now, when a user wants to decrease their indentation, it will do it one tab at a time.
Ok @mxstbr, I fixed the multiline issue. In doing so, I also added support for 'default tab size' to be optionally passed through to the onTab() method as a third parameter. This allows for an editor to have it's own declared tab spacing setting instead of just reading the indentation spacing (although that is a fallback if the tabSize is set to null). This is important because, with knowledge of an individual tab size, we can decrease indentation one tab at a time instead of just removing all spaces at the beginning of the line. I'm glad to discuss alternative implementations also, but I needed something in place in order to handle true tab-by-tab decreasing. If you agree with my implementation, then I'd be happy to update the documentation also, but I wanted to give you a chance to review it first. |
@mxstbr Is there anything I can update or issues I can fix or would you like to discuss alternative approaches to help resolve this? |
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.
Oh sorry, I totally missed this. As long as the explicit value passed to onTab
is optional/a fallback and we still infer tab size based on the rest of the code block I'm happy with this change and would love an update to the docs!
Ok, sounds good. I'll update the docs and let you know when it's ready. |
ETA when this will merge? |
Whenever @cbeninati adds stuff to the docs! |
- also added a new test for Shift+Tab support of custom tab sizes - some code cleanup - some miscellaneous documentation cleanup for consistency
@mxstbr Apologies for the delay. I diverted from the DraftJS project I was using this for. |
@mxstbr Let me know if anything's missing from the documentation. There wasn't much to do. |
@cbeninati Any chance you can fix the problem described by @mxstbr ? I'd really appreciate this getting merged. Thanks for all your work. |
Will this be merged soon? Would love to have Shift Tab functionality |
No description provided.