Summary: | REGRESSION (Safari 5?): Pasting a line into textarea inserts two newlines | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Alexey Proskuryakov <ap> | ||||
Component: | HTML Editing | Assignee: | Ryosuke Niwa <rniwa> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | divya, enrica, marijnh+webkit, rniwa, shezbaig.wk, simon.fraser, tkent, tony, webkit-bug-importer | ||||
Priority: | P2 | Keywords: | InRadar | ||||
Version: | 528+ (Nightly build) | ||||||
Hardware: | Mac | ||||||
OS: | OS X 10.6 | ||||||
Attachments: |
|
Description
Alexey Proskuryakov
2010-11-09 17:11:07 PST
CodeMirror (http://codemirror.net) uses a textarea in a way that makes this bug extra visible. I've had several people report it as a bug in CodeMirror in the past few months [1][2][3], and in fact ran into it writing this very comment in the bug tracker. This seems a serious, obviously reproduceable bug. I hope it's still on someone's list? (Has been sitting idle in the bug tracker for a long time now.) [1]: https://github.com/marijnh/CodeMirror2/issues/598 [2]: https://github.com/marijnh/CodeMirror2/issues/474 [3]: http://groups.google.com/group/codemirror/browse_thread/thread/9b42dec8a17a2dc1 This is also important for Adobe's Brackets editor. Fix: Index: Source/WebCore/editing/ReplaceSelectionCommand.cpp =================================================================== --- Source/WebCore/editing/ReplaceSelectionCommand.cpp (revision 121106) +++ Source/WebCore/editing/ReplaceSelectionCommand.cpp (working copy) @@ -123,9 +123,12 @@ // The two positions above are the same visual position, but we want to stay in the same block. Node* enclosingBlockNode = enclosingBlock(pos.containerNode()); for (Position nextPosition = pos; nextPosition.containerNode() != enclosingBlockNode; pos = nextPosition) { + if (lineBreakExistsAtPosition(pos)) + break; + if (pos.containerNode()->nonShadowBoundaryParentNode()) nextPosition = positionInParentAfterNode(pos.containerNode()); - + if (nextPosition == pos || enclosingBlock(nextPosition.containerNode()) != enclosingBlockNode || VisiblePosition(pos) != VisiblePosition(nextPosition)) I'll post a patch tomorrow. Maybe caused by http://trac.webkit.org/changeset/55762 ? (In reply to comment #5) > Maybe caused by http://trac.webkit.org/changeset/55762 ? Seems possible. I probably didn't consider the impact on plain text by moving to an equivalent visual position. Created attachment 149714 [details]
Fixes the bug
Thank you for figuring this out! Comment on attachment 149714 [details] Fixes the bug View in context: https://bugs.webkit.org/attachment.cgi?id=149714&action=review > LayoutTests/ChangeLog:8 > + Add a test regerssion test for copying & pasting a line in pre into textarea twice. Typo regression and I think you don't mean to say test twice. Committed r121357: <http://trac.webkit.org/changeset/121357> |