adobe / brackets

An open source code editor for the web, written in JavaScript, HTML and CSS.
http://brackets.io
MIT License
33.25k stars 7.63k forks source link

Pasting in multiple lines working incorrectly #11832

Open ArturJanik opened 9 years ago

ArturJanik commented 9 years ago

Result: Copied line gets pasted only in first cursor position (Step 1a) or second cursor position (Step 1b).

The problem occurs always when I'm trying to copy n lines into n positions. Brackets tries to insert each of selected lines individually in succeeding cursor position instead of pasting whole selected content.

I also believe there's some kind of problem with how line breaks are being copied and pasted, which results in this problem. Probably, step 1a leads to copying whole line and line break after it, and step 1b leads to copying whole line and line break before it.

I hope the whole thing is not intented behavior.

Windows 7 64

petetnt commented 9 years ago

Can confirm, filed an issue upstream at codemirror/CodeMirror/issues/3604

redmunds commented 9 years ago

The problem occurs always when I'm trying to copy n lines into n positions.

If you have n selections, then this is how it's supposed to work. But if you select n lines in 1 selection, then it will work as you want.

The first issue you describe only happens if you also select the trailing newline. I'm not sure if it's a known issue, but you can workaround it by selecting everything on line except newline char.

ArturJanik commented 9 years ago

If you have n selections, then this is how it's supposed to work.

Yes, I know, and it's how I expected it to work. But...

But if you select n lines in 1 selection, then it will work as you want.

No, it wont. When you select n lines in 1 selection, and then try to copy it in n places, the result will be the same as when you select n lines in n selections. I'm pretty sure it didn't act like that in previous versions.

Current result when three lines are selected in one selection: untitled-1

Expected result: expected

redmunds commented 9 years ago

It works for me if I also select the trailing newline on the last line, so selection looks like this:

multi-select

If you're interested in the implementation details, multiple selections are separated using newline on the clipboard so when the selection itself has newlines, it's sometimes tricky to determine the intent. Hope this helps.

petetnt commented 9 years ago

The triple click -> weird pasting behavior is an browser bug by the way, so that will need an CEF update unless CodeMirror hacks around it :hammer: