platers / obsidian-linter

An Obsidian plugin that formats and styles your notes with a focus on configurability and extensibility.
https://platers.github.io/obsidian-linter/
MIT License
1.21k stars 82 forks source link

Bug: Breaking multicursor-multiline cut and paste #480

Closed FractalZeroFive closed 1 year ago

FractalZeroFive commented 1 year ago

Linter is breaking multicursor functionallity.

If i hold shift+alt and mark a part in a table as below.

image

then cut the text out

image

move all the cursors down a step with arrow keys and paste i get.

image

Notice how each individual cursor only paste the text it cut before and not all the text. This is correct behavior.

If I do the same with linter enabled i get the following when I paste.

image

Each individual cursor pastes all the text and not just the corresponding text that it is supposed to.

pjkaufman commented 1 year ago

Thanks for reporting this. I do see that this is an issue. The problem I am seeing with this is multicursor-multiline pasting has not been accounted for.

Is your intent to use the Linter option to paste or do you intend to paste the content as is? If the latter, have you tried the command to paste text as it is via the Linter command? I am not sure if that works in this case.

I will reach out to the dev community and see if they are familiar with how to detect a multiline multicursor paste.

pjkaufman commented 1 year ago

The info in this stack overflow post may be useful, so I am adding it here for reference for later: https://stackoverflow.com/questions/9492842/does-codemirror-provide-cut-copy-and-paste-api

ArwensAbendstern commented 1 year ago

Not a developer: I want to confirm it's not just multi-cursor multi-line cut/copy & paste that's broken — I confirmed the same with multiline single cursor. Not sure if that makes a difference, but wanted to report it in case it does.

Also, I seem to see a curios behaviour where the Obsidian file freezes, can no longer be navigated and all that's left for me to do is quit the app and restart.

I'm on a MacBook, CPU is going up high for Obsidian, in the copy&paste scenario. The app itself doesn't seem to freeze but I can't navigate out of the open file to close it without closing the app.

pjkaufman commented 1 year ago

Not a developer: I want to confirm it's not just multi-cursor multi-line cut/copy & paste that's broken — I confirmed the same with multiline single cursor. Not sure if that makes a difference, but wanted to report it in case it does.

Also, I seem to see a curios behaviour where the Obsidian file freezes, can no longer be navigated and all that's left for me to do is quit the app and restart.

I'm on a MacBook, CPU is going up high for Obsidian, in the copy&paste scenario. The app itself doesn't seem to freeze but I can't navigate out of the open file to close it without closing the app.

I am not entirely certain that the slow down you reference is related to copying and pasting. Do you have a reproducible file I could try against? If it is a large file, it could be related to #458.

Was there another type of issue you were referring to that could be related to copying and pasting?

Edit: could you confirm that if you turn off the Linter, the CPU usage does not increase on copy and paste?

pjkaufman commented 1 year ago

I have a partial fix for this. The main issue I am running into with the issue with multiline multicuror pasting is that I am not seeing how to properly retain the multiline multicusor mode and properly move the cursors. I am reaching out to the dev community for some help around this.

pjkaufman commented 1 year ago

Dev note: it looks like I should be able to use replaceSelections if that is available on the Obsidian editor.

Here is the documentation reference.

If this is not an option. I will be forced to either have the cursor show at the same place it was before paste or follow the suggestions provided by the plugin dev group.

pjkaufman commented 1 year ago

I have not gotten a response, so I will "monkey patch" it as they normal say. So it will just not move the cursor to the end of the pasted values when doing a multicursor multiline paste. If someone does know how to update a specific cursor position, please let me know how.

pjkaufman commented 1 year ago

This should be fixed on master and in the next release. Please let us know if the issue continues to exist.

sglowa commented 1 year ago

the issue returned after updating to 1.19.1 (but i dont remeber from which version) :^( obisidian version 1.4.5

pjkaufman commented 1 year ago

@sglowa , I don't recall ever addressing multicursor cut, so that could be new. As for the other issue, I will have to see if I can reproduce with the steps listed above.

pjkaufman commented 1 year ago

@sglowa , do you have any paste settings enabled? If not, I may just disable paste override for when no paste rules are active to reduce the likelihood of this kind of issue.

pjkaufman commented 1 year ago

Looks like I have a solution. I just need to verify that the logic is handled properly. I will also add a check to make sure it does not override the paste functionality if the paste rules are not enabled.

pjkaufman commented 1 year ago

I am pushing up a fix that should be in the next release which will hopefully get pushed soon. Thanks for reporting the issue @sglowa

sglowa commented 1 year ago

nice, thanks for addressing it so rapidly

On Thu, Sep 7, 2023, 01:00 Peter Kaufman @.***> wrote:

I am pushing up a fix that should be in the next release which will hopefully get pushed soon. Thanks for reporting the issue @sglowa https://github.com/sglowa

— Reply to this email directly, view it on GitHub https://github.com/platers/obsidian-linter/issues/480#issuecomment-1709234096, or unsubscribe https://github.com/notifications/unsubscribe-auth/AFKMWULVCJCT3PBX73CCMHDXZD6A7ANCNFSM6AAAAAARZSJL7A . You are receiving this because you were mentioned.Message ID: @.***>