awth13 / org-appear

Toggle visibility of hidden Org mode element parts upon entering and leaving an element
MIT License
383 stars 19 forks source link

Should hide emphasis sooner #16

Closed tecosaur closed 3 years ago

tecosaur commented 3 years ago

Hello,

I found this package great for the most part, I've just got one small niggle with it. If my cursor is at the end of a line like: bold *text*  despite having a space between the cursor and the emphasised word, the emphasis markers are shown. If the cursor is left in the same position but a character added after it (i.e. the line is now bold *text* a and the cursor is on the left of the a) org-appear hides the emphasis markers as desired.

This delay/inconsistency is a tad annoying though. It would be great if this corner case could be handled :slightly_smiling_face:

awth13 commented 3 years ago

Hello, @tecosaur! Thank you for posting the issue!

There are two dimensions to this problem, both due to the org-element API counting whitespace after an element as part of the element.

  1. An element that was not active is toggled prematurely, before the cursor enters it visually.
  2. An element that was active is toggled with a delay, requiring the user to type something after the element.

The first one is resolved here but the second one is more inconvenient. Without going into much detail as to why -- basically, since the post-cmd hook runs after each command, I am not keen on adding boundary checks to it -- I wanted to tell you that I am aware of this issue and working on addressing it.

tecosaur commented 3 years ago

Thanks for getting back to me, and it's good to hear that you're going to try to sort this out!

awth13 commented 3 years ago

This issue is now resolved. For now, however, org-appear allows one whitespace after an element. This is because toggling of nested elements breaks otherwise.

*This is bold text with nested /italics/ text*
                                        ^

org-element considers the point marked on the illustration part of the child element. If we don't do this as well, org-appear will hide the parent emphasis markers when the cursor is at this point.

tecosaur commented 3 years ago

Nice! Thanks for working on this