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
U+0000 pasted with subsequent cursor position problems #146326
Comments
@h-h-h-h I see the null character rendered by the editor. Here is the file which I used: 146326.txt. I clicked "Open anyway" when VS Code warned that the file is binary and the character is rendered for me: Did you by any chance turn off "Render Control Characters"? |
The bug description is still valid. My settings when searching for "Render Control Characters": Your file after clicking "Open anyway" and pasting what I described above (the yellow thingy is new for me; I believe it also appears on German characters "äöüß"): After step 5 and first part of 6 ("5. Place cursor at start of a [newly pasted] line with visible characters (not the first)." "6. Press Backspace After last part of step 6: After inserting an additional character at the very start of every line: BTW: The yellow-rectangle and cursor position problem is the same when I replace U+0000 with "U+200C ZERO WIDTH NON-JOINER [ZWNJ]". When navigating vertically -- not horizontally -- this behavior should be corrected so that the arrow keys behave as expected. Horizontally, the cursor must still halt on zero-width chars, should you decide to keep them displayed as such (which is also debatable in a monospace editor). (And, in that case, having the cursor to the logical right of a zero-width char and pressing Up, then Down, should IMO place the cursor to the logical left of the zero-width char.) For ZWNJ, the yellow rectangle makes sense. But U+0000, when pasting, should be displayed the same as when opening a file with it. |
BTW: Since the "NUL" block that is displayed is wider than a regular character, navigating between lines with arrow keys where one line has a "NUL" block is also off (lines with similar length, navigating after the "NUL" block). That is, alternating Up and Down leads to different displayed cursor positions where they should be identical. The "NUL" block should be the width of one character. Or the width of two in conjunction with cursor position correction? |
Related: #2878 |
@h-h-h-h In your original description, you mention |
More problems/inconsistencies:
My check with the hex editor HxD was flawed, because it only accepts code points up to U+00FF when pasting. In "A█B" with a high code point, the block is also made into byte "00". I now used the clipboard inspection tool InsideClipboard (an OS-level app) to check what's really going on. First, the behavior of Firefox is inconsistent. It copies different sets of formats when you copy via context menu vs. via Ctrl+C from the dev console. With context menu, it's just "CF_UNICODE_TEXT" and "CF_TEXT". I configured InsideClipboard so that is displayed a hex dump, and "U+200B ZERO WIDTH SPACE [ZWSP]" in UTF-16LE was revealed: "0D 00 0A 00 0B 20 0D 00 0A 00". This is also what VS Code saves: 1.txt, 2.txt. So, this navigation problem isn't about U+0000. But the problem is still real and is related to differing character widths: It's present for the zero-width space, for special code point representations as null in your example file, and obviously more chars of deviating width. |
This is how the Windows OS works, this is nothing something specific to VS Code. The plaintext clipboard in Windows cannot hold text containing NULL.
This is the Unicode Highlighting feature that you're running into. It highlights special characters, including confusables and invisibles. This feature always works for me. Based on the latest information, here is a text file that contains both the NULL character and the U+200B ZERO WIDTH SPACE character and here is how it is rendered in VS Code: This looks correct to me. Please let me know if this doesn't look correct to you. |
Thank you for your feedback. This is a well known problem, the cursor up and down movements do not operate on effective horizontal character offsets. See #142738 (comment) |
Does this issue occur when all extensions are disabled?: N/A
Steps to Reproduce:
console.log([ "foo", "bar" ])
Array
item and copy 2 or more lines from theArray [...
to the<prototype>...
line....0d 0a 00 0d 0a...
I'm not sure whether pasting U+0000 should just be prevented. It definitely shouldn't be displayed with zero-width however.
The text was updated successfully, but these errors were encountered: