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

Obsidian.md: Undo (Ctrl+Z) undoes more than one last step #6759

Closed
mikkovedru opened this issue Aug 2, 2021 · 4 comments
Closed

Obsidian.md: Undo (Ctrl+Z) undoes more than one last step #6759

mikkovedru opened this issue Aug 2, 2021 · 4 comments

Comments

@mikkovedru
Copy link

@mikkovedru mikkovedru commented Aug 2, 2021

I am using Obsidian knowledge base editor.

I found a bug in it, reported it to the developers, but it was shot down on the grounds of "it is a CodeMirror bug". Hence I am writing to you.

Here is a copy&paste of my original bug report:


Steps to reproduce

  1. Install Obsidian.
  2. Go to any youtube video (for example here)
  3. Select one line with the name of the channel (in this case “DistroTube”)
    image
  4. Write "Test " in a document.
  5. Press Ctrl+Ins(Ctrl+C) to copy.
  6. Go to Obsidian document and write "Test ".
  7. Press Shift+Ins (Ctrl+V) to paste. The result should look like this:
Test [DistroTube](https://www.youtube.com/channel/UCVls1GmFKf6WlTraIb_IaJg)

image
7. BUG: Press Ctrl+Z to undo. You will see that the whole line will be deleted, not only the youtube link.

Expected result

Only the last step should be undoed. Typing and pasting are clearly two different steps/activities.
Environment

  • Operating system: Linux Mint 20.2 Cinnamon
  • Obsidian version: 0.12.10

Additional information

This bug shows itself with youtube channel links. Everything works fine with most other copy-pasted text. Including if you paste+select+copy the same exact youtube channel link and try to reproduce the bug…


@marijnh
Copy link
Member

@marijnh marijnh commented Aug 3, 2021

Sorry, I'm not debugging problems that involve integrations. And more generally, not very sure that this is a CodeMirror bug. It sounds like the Obsidian link pasting behavior replaces the entire line, and that's what's causing this behavior.

@marijnh marijnh closed this Aug 3, 2021
@lishid
Copy link
Contributor

@lishid lishid commented Aug 12, 2021

Got word of this recently. Here's the repro on https://codemirror.net/:

Type this into console:

editor.on('paste', (cm, e) => {
  cm.replaceSelection('test');
  e.preventDefault();
});

Create new line, then type anything, then paste anything, then undo undoes both the typing and pasting.

@marijnh
Copy link
Member

@marijnh marijnh commented Aug 12, 2021

That's by design -- replaceSelection defaults to setting the "origin" of the change to +input, which allows the change to be merge with other plain input changes. Call .replaceSelection("test", false, "customOrigin") to avoid this.

@lishid
Copy link
Contributor

@lishid lishid commented Aug 12, 2021

Ah I see, thanks for the response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants