-
Notifications
You must be signed in to change notification settings - Fork 325
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
Move cursor after bold or italic span without toggling, iff it's at the end of text right before the delimiter #1
Conversation
… *if and only if* cursor is at end of word but still inside of wrap.
Good idea 👍 |
src/formatting.ts
Outdated
if (selection.isEmpty) { | ||
let position = selection.active; | ||
|
||
selection = new Selection(new Position(position.line, position.character - startPattern.length), position); |
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 find this line will fail when the cursor is at an empty newline 😔
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.
Oops. I did not think to test that. I will try to fix it.
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 fixed it and pushed the change.
BTW, do you have a good description about the toggling behavior to put in the README? I prefer this format,
But I don't know how to properly describe it 😅 |
I am glad you like the idea. Here is how I describe the functionality:
This does not cover underscore styles. I don't know if that matters. Also if the user presses a hotkey to make text bold or italic when no text is selected, the asterisks are placed around the cursor but if the user presses the hotkey again without typing anything in the text, the extension adds more asterisks around the cursor instead of removing the "unwanted" ones. I almost fixed this but then I realized how this can be useful in certain situations so I left it alone. I'm not sure how you want to handle that, if at all. |
Thanks! |
I'm not sure yet how I will fix that. |
OK, I will work it out later. Thanks again. |
I wanted the bold and italics toggles to work more like the way they do in Google Docs where the user can toggle bold to "on", type the word or words they want, then toggle bold to "off" to keep typing in normal style.
The way I accomplished this in the code is to have the cursor jump to outside of the "*" or "**" in the markdown if the user hits the keyboard shortcut again while the cursor is at the end of the bold text but still inside of the asterisks.
In other words, if the user hits
Ctrl+B
when the cursor is at:the cursor will jump two places to the right:
and the user can keep typing as normal without having to hit the "end" key or use the mouse.