Looks like a recently introduced bug. When pasting text ending with a
newline, an extra newline is introduced.
Pasting "abc\n" three times yields "abc\n\nabc\n\nabc\n". It works as
expected if pasting is interleaved with mouse clicks. Perhaps the
cursor position is not being set correctly after pasting?
I just tried to reproduce this at: http://codemirror.net/mode/clike/index.html Pasting abc\n on line 2 does not create a newline for me. When pressing enter after abc\n I get a newline with indention. Not sure if this is standard behaviour.
> Looks like a recently introduced bug. When pasting text ending with a > newline, an extra newline is introduced.
> Pasting "abc\n" three times yields "abc\n\nabc\n\nabc\n". It works as > expected if pasting is interleaved with mouse clicks. Perhaps the > cursor position is not being set correctly after pasting?
> Bobby
> -- > You are receiving this because you are currently a member of the > CodeMirror Google group. To send something to list, use > codemirror@googlegroups.com, to unsubscribe, send a message to > codemirror-unsubscribe@googlegroups.com.
This appears to be a Webkit bug that's been open for over a year [1]. CodeMirror uses a textarea to read input, so bugs in the underlying textarea implementation will shine through. A workaround with adding extra bogus characters to the end of the textarea would be possible, but I think this isn't a major enough problem to justify such an invasive hack, which is likely to cause new issues. So I guess putting pressure on the Webkit people to fix this is your best option.
Sorry, I don't get it. When pasting abc\n in a textarea in a WebKit browser(Canary, Safari tested W7) doesn't give me a new line at all. Demo: http://jsfiddle.net/fxKXS/ Only 1 newline when pressing enter.
> This appears to be a Webkit bug that's been open for over a year [1]. > CodeMirror uses a textarea to read input, so bugs in the underlying > textarea implementation will shine through. A workaround with adding > extra bogus characters to the end of the textarea would be possible, > but I think this isn't a major enough problem to justify such an > invasive hack, which is likely to cause new issues. So I guess putting > pressure on the Webkit people to fix this is your best option.
> -- > You are receiving this because you are currently a member of the > CodeMirror Google group. To send something to list, use > codemirror@googlegroups.com, to unsubscribe, send a message to > codemirror-unsubscribe@googlegroups.com.
> You have to paste it multiple times in a row, as described in the > original report.
> -- > You are receiving this because you are currently a member of the > CodeMirror Google group. To send something to list, use > codemirror@googlegroups.com, to unsubscribe, send a message to > codemirror-unsubscribe@googlegroups.com.
>> You have to paste it multiple times in a row, as described in the >> original report.
>> -- >> You are receiving this because you are currently a member of the >> CodeMirror Google group. To send something to list, use >> codem...@googlegroups.com <javascript:>, to unsubscribe, send a message >> to codemirror-...@googlegroups.com <javascript:>.
There's the 'paste' event, which fires right *before* a paste, but is
not entirely reliable.
This bug has been fixed in Webkit. I guess, but haven't tested that
Chrome's dev channel already contains the fix. So my plan is to just
ride it out, since Chrome users upgrade quickly.