Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Apply formatting to current word when there is no selection #57

Closed
adunning opened this issue Jul 18, 2015 · 6 comments
Closed

Apply formatting to current word when there is no selection #57

adunning opened this issue Jul 18, 2015 · 6 comments

Comments

@adunning
Copy link

Presently, if the cursor is placed in the middle of the word and one of the formatting commands is invoked, one will merely receive the appropriate characters on each side of the cursor. With the TextMate Markdown package (see https://github.com/textmate/markdown.tmbundle/tree/master/Commands), this action will result in the formatting being applied to the entirety of the current word (minus any punctuation), which is useful; would it be possible to implement this?

@zhuochun
Copy link
Owner

May I confirm the behavior when cursor is is inside a middle of the formatted text, and trigger the format command again? It will toggle format or insert format?

@adunning
Copy link
Author

That's an interesting point: the TextMate 2 behaviour is to trigger it again: **bolded** becomes ****bolded**** if one moves the cursor back into the word and types + b a second time. Removing it the second time would probably be more ideal, but I'm not sure whether that's feasible.

In my experience, the main undesirable aspect of the TextMate implementation is that, if the cursor is placed after a piece of punctuation at the end of a word and + i (etc.) is invoked, one gets something like example*,*. (I would expect either *example,* or *example*,.)

zhuochun added a commit that referenced this issue Jul 19, 2015
@zhuochun
Copy link
Owner

@adunning i added this behaviour in the latest release. please try it out 👯

@adunning
Copy link
Author

That's absolutely wonderful; thank you! The only oddity I'm seeing is that it's being invoked twice every time, appending additional characters to the word: placing the cursor in word and typing + b results in **word******.

@zhuochun
Copy link
Owner

Em. I see the problem with **word**_, becomes **word****_**,. Might due to how Atom handles the boundary between word and non-word chars. I will check again :D

@adunning
Copy link
Author

That's fairly minor; your implementation is even better than TextMate's otherwise. The problem I was having with the commands being run twice disappeared after I uninstalled the package and re-added it. Thanks again!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants