Skip to content
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

Doesn't work right with multiple text selections #48

Closed
joem opened this issue May 20, 2023 · 8 comments
Closed

Doesn't work right with multiple text selections #48

joem opened this issue May 20, 2023 · 8 comments
Labels
enhancement New feature or request

Comments

@joem
Copy link

joem commented May 20, 2023

I was attempting to uppercase text in a few different places, so I made multiple selections (by holding Option while selecting additional things) and I invoked Text Format: Uppercase Selected Text via the command palette. Instead of correctly uppercasing everything, it uppercased the last selection and then replaced all previous selections with the uppercased last selection.

I'm using Version 1.1.16 (Installer 1.0.0) of Obsidian and version 2.2.1 of Text Format. Let me know if you need any more details/info. I tried it a few times in a few documents and it seems to work consistently like that for me.

I glanced through the open and closed issues and didn't see any mention of this, but maybe it was phrased a way I wasn't looking for, so if this is a duplicate issue, sorry about that.

(I've been using this plugin for a while and really love this plugin. Even without working right on multiple selections, it's still such a useful plugin! Thanks!)

@erroreyes
Copy link

erroreyes commented Jun 12, 2023

It would be great for this to be possible. I installed the plugin a few days ago specifically to perform case changes for multiple selections and lines.

@Benature Benature added the help wanted Extra attention is needed label Jul 23, 2023
@Benature
Copy link
Owner

That is a good suggestion. However, I do not know how to get the multi-selection via the Ob's API. In my tests, method .getSelection() can only get the first selection, but all multi-selections are replaced with the formatted result of the first selection.

@Benature Benature added the enhancement New feature or request label Jul 23, 2023
@erroreyes
Copy link

I don't know the API at all, but I took a quick look and there seems to be an Editor.getRange() method that makes me wonder if that would help in achieving this.

@Benature
Copy link
Owner

Benature commented Mar 15, 2024

Sorry that I did not reply this issue in time.

getRange(from, to) is useful to get the text from the specific range. However, I need to get the cursor's position at the first. In my test, editor.getCursor() can only get the first position even though I've set several cursors.

I'm eager to implement this feature as well. But still have no idea for now. 😢

@Benature
Copy link
Owner

Good news, I just read the api again, found listSelections. It works! Now I can get the positions of multi-cursor. :)

@Benature Benature removed the help wanted Extra attention is needed label Mar 15, 2024
Benature added a commit that referenced this issue Mar 15, 2024
@Benature
Copy link
Owner

To support multi-cursor, refactoring the code is needed. I've just made the basic refactoring. I beta pre-release 3.0.0-b1 is just released. Anybody who is interested is welcome to install the beta version and test it!

I expect these commands should work well:

"lowercase"
"uppercase"
"capitalize-word"
"capitalize-sentence"
"titlecase"
"togglecase"

Other commands may have a wrong selection at last. Please tell me if you find something wrong!


To install the beta version, you can install it by BRAT (https://github.com/TfTHacker/obsidian42-brat), and check if it is a beta version.

@erroreyes
Copy link

v3.0.0-b1 seems to be working well so far. I'll be using it all day today at work and see if anything strange happens.

Thank you for finding the time to fix this!

Benature added a commit that referenced this issue Mar 16, 2024
Benature added a commit that referenced this issue Mar 16, 2024
Benature added a commit that referenced this issue Mar 18, 2024
@Benature
Copy link
Owner

v3.0.0 is released finally. Feel free to re-open this issue if something is wrong :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants