Skip to content

Line-based Copy/Paste has different behavior on Windows vs. Linux #6337

Closed
@lincolnpgoog

Description

@lincolnpgoog

When using line-based (no highlighting) copy-paste, there is different behavior between Windows and Linux. The Linux behavior is preferred, as it is similar to other text or code editors like Notepad++ or Visual Studio.

Environments Tested

Browsers Tested:

  • Chrome 83.0.4103.116 (Official Build) (64-bit) on Windows 10 Version 1903
  • Chrome 83.0.4103.112 (Official Build) (64-bit) on ChromeOS

I'm not sure what version of CodeMirror is being used, but my example was created using the https://codemirror.net demo box at the time of writing up this issue.

Steps to Reproduce

  1. Visit https://codemirror.net/ in the browser
  2. Using the demo panel on the page, place the cursor anywhere in the middle of a line of text. Do not highlight any text.
  3. Press Ctrl+C to copy the line.
  4. Move the cursor to any other line of text, anywhere within the line. Do not highlight any text.
  5. Press Ctrl+V to paste. This is where the behavior differs.

Example

In the example that follows | indicate the copy position, and ^ indicates the paste position:

<!-- Create a simple CodeMirror instance -->
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<script>
  var editor = CodeMirr|or.fromTextArea(myTextarea, {
    lineNum^bers: true
  });
</script>

On ChromeOS/Linux, this is the result, which is desirable and expected:

<!-- Create a simple CodeMirror instance -->
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<script>
  var editor = CodeMirror.fromTextArea(myTextarea, {
  var editor = CodeMirror.fromTextArea(myTextarea, {
    lineNumbers: true
  });
</script>

On Windows, this is the result, which is problematic and unexpected (note that the line was embedded in the middle of the paste position, rather than being placed above it):

<!-- Create a simple CodeMirror instance -->
<link rel="stylesheet" href="lib/codemirror.css">
<script src="lib/codemirror.js"></script>
<script>
  var editor = CodeMirror.fromTextArea(myTextarea, {
    lineNum  var editor = CodeMirror.fromTextArea(myTextarea, {
bers: true
  });
</script>

As someone who regularly switches between Windows and Linux, it would be useful to be consistent between the versions, preferably in favor of the way the Linux version handles it. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions