RESOLVED FIXED 92812
Smart link can erroneously move caret after an URL when typing immediately before it
https://bugs.webkit.org/show_bug.cgi?id=92812
Summary Smart link can erroneously move caret after an URL when typing immediately be...
Mark Rowe (bdash)
Reported 2012-07-31 16:39:47 PDT
* SUMMARY When editing text in a text area that contains a URL, the caret will often jump forward unexpectedly. * STEPS TO REPRODUCE 1. Load <http://webkit.org/new-bug> 2. Type the text http://webkit.org/ in to the Description field. 3. Press Ctrl-A to move the caret to the beginning of the line, before the "h". 4. Type Before and press space. * RESULTS The caret jumps to the end of the URL in the text area. * NOTES This broke in <http://trac.webkit.org/changeset/117590>. <rdar://problem/11994169>
Attachments
Demo (disable 'Check Spelling While Typing' and enable 'Smart Links') (390 bytes, text/html)
2013-02-01 00:48 PST, Ryosuke Niwa
no flags
Same reduction but reproduces the bug in DRT (719 bytes, text/html)
2013-02-01 01:01 PST, Ryosuke Niwa
no flags
Patch (4.99 KB, patch)
2013-02-01 02:12 PST, Ryosuke Niwa
enrica: review+
buildbot: commit-queue-
Ryosuke Niwa
Comment 1 2012-10-19 14:07:17 PDT
I can't reproduce this issue anymore.
Mark Rowe (bdash)
Comment 2 2012-10-19 14:14:53 PDT
I just noticed that this only reproduces if you have the Smart Links option enabled in the Substitutions part of the context menu.
Yi Shen
Comment 3 2012-10-26 16:58:44 PDT
Mark, could you double check this issue. I couldn't reproduce it with the latest mac build. (In reply to comment #2) > I just noticed that this only reproduces if you have the Smart Links option enabled in the Substitutions part of the context menu.
Mark Rowe (bdash)
Comment 4 2013-01-29 13:27:14 PST
If you can’t reproduce this, try quitting Safari, doing “defaults write com.apple.Safari WebAutomaticLinkDetectionEnabled -bool YES”, and then attempt to reproduce again.
Mark Rowe (bdash)
Comment 5 2013-01-29 14:15:31 PST
There's one additional piece that's missing: continuous spell checking must be disabled in order to reproduce. The following steps are what is necessary in order to reproduce: 1. Load <http://webkit.org/new-bug> 2. Right-click in the Description field, choose Spelling and Grammar and disable Check Spelling While Typing. 3. Right-click in the Description field, choose Substitutions and enable Smart Links. 4. Type the text http://webkit.org/ in to the Description field. 5. Press Ctrl-A to move the caret to the beginning of the line, before the "h". 6. Type Before and press space. 
Ryosuke Niwa
Comment 6 2013-02-01 00:41:47 PST
(In reply to comment #5) > There's one additional piece that's missing: continuous spell checking must be disabled in order to reproduce. > > The following steps are what is necessary in order to reproduce: > 1. Load <http://webkit.org/new-bug> > 2. Right-click in the Description field, choose Spelling and Grammar and disable Check Spelling While Typing. > 3. Right-click in the Description field, choose Substitutions and enable Smart Links. > 4. Type the text http://webkit.org/ in to the Description field. > 5. Press Ctrl-A to move the caret to the beginning of the line, before the "h". > 6. Type Before and press space. It seems like in step 6, you need to misspell "before".
Ryosuke Niwa
Comment 7 2013-02-01 00:48:02 PST
Created attachment 185970 [details] Demo (disable 'Check Spelling While Typing' and enable 'Smart Links')
Ryosuke Niwa
Comment 8 2013-02-01 00:50:01 PST
By the way, I'm not sure if it's really accurate to blame http://trac.webkit.org/changeset/117590 here since that patch merely re-enabled smart links. Prior to that patch, smart link was completely broken. It's possible that we had this bug before r117590.
Mark Rowe (bdash)
Comment 9 2013-02-01 00:57:39 PST
This also reproduces for me in a slightly different form in this "Additional Comments" text field by typing "http://webkit.org foo bar baz". It comes out as "http://webkit.org baz bar foo", as the cursor is moving unexpectedly as I type.
Ryosuke Niwa
Comment 10 2013-02-01 01:01:15 PST
Created attachment 185971 [details] Same reduction but reproduces the bug in DRT
Ryosuke Niwa
Comment 11 2013-02-01 01:49:05 PST
I think I have a fix for this. It's a one-liner :)
Ryosuke Niwa
Comment 12 2013-02-01 02:12:10 PST
Ryosuke Niwa
Comment 13 2013-02-01 02:13:01 PST
Comment on attachment 185986 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=185986&action=review > Source/WebCore/editing/Editor.cpp:2131 > + if (result->type == TextCheckingTypeLink > + && (selectionOffset > resultEnd + 1 || selectionOffset <= resultLocation)) On my second thought, I should probably fit this in one line.
Build Bot
Comment 14 2013-02-01 06:07:21 PST
Comment on attachment 185986 [details] Patch Attachment 185986 [details] did not pass mac-wk2-ews (mac-wk2): Output: http://queues.webkit.org/results/16298627 New failing tests: editing/inserting/smart-link-when-caret-is-moved-before-URL.html
Ryosuke Niwa
Comment 15 2013-02-01 10:42:18 PST
(In reply to comment #14) > (From update of attachment 185986 [details]) > Attachment 185986 [details] did not pass mac-wk2-ews (mac-wk2): > Output: http://queues.webkit.org/results/16298627 > > New failing tests: > editing/inserting/smart-link-when-caret-is-moved-before-URL.html This test probably needs to be disabled on WK2 due to WTR's missing method.
Enrica Casucci
Comment 16 2013-02-01 11:34:07 PST
Comment on attachment 185986 [details] Patch Looks good to me. Thanks for fixing this!
Ryosuke Niwa
Comment 17 2013-02-01 11:46:05 PST
Jessie Berlin
Comment 18 2013-02-01 12:23:52 PST
Note: editing/inserting/smart-link-when-caret-is-moved-before-URL.html uses setAutomaticLinkDetectionEnabled, which is not implemented for WebKitTestRunner (https://bugs.webkit.org/show_bug.cgi?id=87162). I am going to skip that test in the wk2 TestExpectations file.
Jessie Berlin
Comment 19 2013-02-01 12:30:33 PST
(In reply to comment #18) > Note: editing/inserting/smart-link-when-caret-is-moved-before-URL.html uses setAutomaticLinkDetectionEnabled, which is not implemented for WebKitTestRunner (https://bugs.webkit.org/show_bug.cgi?id=87162). I am going to skip that test in the wk2 TestExpectations file. Skipped for wk2 in http://trac.webkit.org/changeset/141627
Note You need to log in before you can comment on or make changes to this bug.