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

Bug: NUL (Char \x00) cannot be displayed and copied. #7029

Open
cyfung1031 opened this issue Mar 12, 2023 · 1 comment
Open

Bug: NUL (Char \x00) cannot be displayed and copied. #7029

cyfung1031 opened this issue Mar 12, 2023 · 1 comment

Comments

@cyfung1031
Copy link

This is only found in CodeMirror5.
It solved in CodeMirror6.

How to fix it in CodeMirror5?

I can use coding to setValue with \x00, I can also define new specialCharPlaceholder to handle the display issue.
But still it cannot be copied. Once it got copied, the Clipboard string will not contain \x00.
Select all -> Cut all -> Paste will remove all \x00.

@cyfung1031
Copy link
Author

I just got an answer by myself.

  editor.on("cut", function (cm, evt) {
    evt.clipboardData.setData('text/plain', cm.getSelection());
    evt.preventDefault();
    setTimeout(() => {
      document.execCommand("delete", false, null);
    }, 0);
  })

  editor.on("copy", function (cm, evt) {
    evt.clipboardData.setData('text/plain', cm.getSelection());
    evt.preventDefault();
  })

I am not sure this is the best way or not.
If you know a better way, please let me know.

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

No branches or pull requests

1 participant