joeyuping / quick_latex_obsidian

MIT License
327 stars 21 forks source link

Superscript Auto-Enclosure deletes normal parentheses. #71

Closed wobbba closed 1 year ago

wobbba commented 1 year ago

If I press space after typing A^(b) it results in A^{b} but I expect it to be A^{(b)}, as is also the case with the subscript version.

joeyuping commented 1 year ago

Hi! @wobbba

Thank you so much for bringing this up! Indeed, I did not consider this usage. I have updated the plugin, please kindly update to v2.5.0. I added a conditional to check that if expression after superscript is enclosed in round brackets () AND enclosed content is more than 3 characters then replacing the () brackets is performed. The replacing brackets operation is retained as it is for cases when the exponential is a long expression that may include spaces which would prematurely trigger the enclose superscript function ; by using () after the ^ sign, the triggering of autoenclose superscript function is suppressed until cursor moves after the ().
For the case you have mentioned, I presumed it would be mostly for indexing? which most likely would not be more than 3 characters? Please see if the changes suits the need :)

The subscript version currently does not have the () replacing function as subscript tends to be short.

wobbba commented 1 year ago

Thank you so much @joeyuping!!

Yes this suits my needs. It is indeed a form of indexing, it pops up in some mathematics but for me mostly in machine learning. Good job on the compromise!