microsoft / microsoft/monaco-editor

[Bug] Copy/pasting multiline content with key:value format in Safari loses line breaks

Open
#3,969 2 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug editor-core help wanted
Dominant language
JavaScript
Stars
46.8k
Forks
4.1k
Avg merge
17h 58m
Merged PRs (30d)
1

Description

Reproducible in vscode.dev or in VS Code Desktop?
  • Not reproducible in vscode.dev or VS Code Desktop
Reproducible in the monaco editor playground?
Monaco Editor Playground Link

https://microsoft.github.io/monaco-editor/playground.html?source=v0.38.0#XQAAAAKiAQAAAAAAAABBqQkHQ5NjdMjwa-jY7SIQ9S7DNlzs5W-mwj0fe1ZCDRFc9ws9XQE0SJE1jc2VKxhaLFIw9vEWSxW3yscwzwauRgmSaumWUF-TBOsVJ4S4FwfCDQb5-2uUHXTVAefbVSd9IzaZ_vv9VR9KugsKioBUYGa0XsnArxmHPolFj8CfzECMW-192L1d0AxNn3frXdATDcOjBDBCfFOP9lxPkDGa94bLCQjig1WeZ-XvLSWLvYAoeBgnD9Y-1FkIZ4ZiDBKGGWqsmNGpBJpSH-BkEAWx_SluutEVJnITCjgHGAPrMlGP_KrBAt_DqFjnhfj3mYSAZ-bePmjIwVfhU3YEf8b4BH-liLT398A8AkESSXsvlH-B47fMM6Pd2k2ONI-s-gNELRvux_997GgA

Monaco Editor Playground Code
const value = /* set from `myEditor.getModel()`: */ `key: thing
otherkey: stuff
foo: bar

key : thing
otherkey : stuff
foo : bar

---
key: thing
otherkey: stuff
foo: bar

`;

// Hover on each property to see its docs!
const myEditor = monaco.editor.create(document.getElementById("container"), {
	value,
	language: "yaml",
	automaticLayout: true,
});
Reproduction Steps

In Safari on MacOS, select multiple lines of text which are of the format key: value, and then paste in a plain text setting, e.g. VSCode, TextEdit, etc. Observe that the text is pasted without line endings - i.e. all on one line.

Note: If pasting into a rich text setting such as Notes app or another Monaco Editor then line endings are correctly preserved.

Actual (Problematic) Behavior

Text is pasted without line breaks.

https://github.com/microsoft/monaco-editor/assets/1550045/404a2e30-595c-47a1-b492-a931526ae516

Expected Behavior

Text is pasted with line breaks in tact.

Additional Context

Safari: Version 16.4 (18615.1.26.110.1)
MacOS: 13.3.1 (a)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Monaco Editor Playground link and the provided TypeScript reproduction, then reproduce the paste behavior in Safari using plain-text and rich-text targets. Trace the editor's clipboard handling for multiline key:value content. Done means pasting into a plain-text setting preserves all line breaks while the existing rich-text behavior remains correct.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.