Repository: vscode-neovim/vscode-neovim (TypeScript)

Issue:
bug: latest dev build is pasting wrong data from buffer.
### Did you check docs and existing issues?

- [X] I have read all the vscode-neovim docs
- [X] I have searched the existing issues of vscode-neovim
- [X] I can reproduce the issue with an empty init.vim/init.lua and no other vscode extensions (when applicable)

### Neovim version (nvim -v)

v0.10.0-dev

### Operating system/version

Ubuntu 23.10

### Describe the bug

I try `dd` a line and then `p` it. I repeat it, and it puts an extra line after it.

I then `dd` another line and `P` it. It pastes the wrong line. See video.

[Screencast from 2023-11-14 08-42-55.webm](https://github.com/vscode-neovim/vscode-neovim/assets/7737834/542e1e0d-778b-4da8-b188-3ba6155d8b73)


### Steps To Reproduce

`dd`, `p`. move to the line and repeat.

go to a line a couple down, `dd` and then `P` that.

Wrong line is pasted.

### Expected Behavior

Right line is pasted, see video.
bug: Normal mode `o` adds an extra new line
### Did you check docs and existing issues?

- [X] I have read all the vscode-neovim docs
- [X] I have searched the existing issues of vscode-neovim
- [X] I can reproduce the issue with an empty init.vim/init.lua and no other vscode extensions (when applicable)

### Neovim version (nvim -v)

NVIM v0.9.2

### Operating system/version

Windows 11 Home 23H2

### Describe the bug

This might be related to #1612.
I was not sure this is the same issue, so I created as a new one.

VSCode version is 1.84.2.

When I press `o` in certain condition, an extra new line was added and breaks functionality of `yy`, `dd`, and visual selection.
This happens when:

* EOL is CRLF (I couldn't reproduce with LF)
* Cursor is on the line with at least one indentation (I couldn't reproduce with no indentation)
* Next line of the cursor is blank

### Steps To Reproduce

I'm going to use this text below to explain.

```txt
Sentence 1
    Sentence 2

Sentence 3
Sentence 4
Sentence 5
Sentence 6
Sentence 7
Sentence 8
Sentence 9
Sentence 10
Sentence 11
```

1. Set the file eol to CRLF
2. Move the cursor to line 2 (that says "Sentence 2")
3. On the normal mode, press `o`

When 3. is done,

* An extra new line was added, instead of 1 new line
* Normal mode `yy` and `dd` went wrong
  * Seems different line is copied to the buffer
* Visual selection went wrong
  * Highlighting with `ggVG` and actual text don't match
* The cursor can't go to the end of the file (last line)
  * When selecting the last line with a mouse, the extention said "nvim_win_set_cursor: Cursor position outside buffer"

https://github.com/vscode-neovim/vscode-neovim/assets/83961834/ecb1d483-e3a0-4d79-a5d0-63ca3c27bed7

### Expected Behavior

Commands work the same way as Neovim itself.

* Just one new line is added
* Copies right line with `yy` and `dd`
* Visual selection works correctly
* The cursor can go to the end of the file


Discussion: Does every file have this issue? Can you upload a file that reproduces the issue?
https://github.com/rayzorben/mudengine/blob/main/src/engine/user.coffee line 572

other files seem fine but I only tested about 3
I can't reproduce 👀 





Fix (patch):
diff --git a/src/document_change_manager.ts b/src/document_change_manager.ts
index 3ba064266..d05992084 100644
--- a/src/document_change_manager.ts
+++ b/src/document_change_manager.ts
@@ -256,9 +256,8 @@ export class DocumentChangeManager implements Disposable {
                         logger.debug(`No visible text editor for document, skipping`);
                         continue;
                     }
-                    const oldText = doc.getText();
-                    const eol = doc.eol === EndOfLine.CRLF ? "\r\n" : "\n";
-                    const newText = newLines.join(eol);
+                    const oldText = doc.getText().replace(/\r\n/g, "\n");
+                    const newText = newLines.join("\n");
                     this.documentSkipVersionOnChange.set(doc, doc.version + 1);
 
                     const cursorBefore = editor.selection.active;