Bug 4062

Summary: Word completion doesn't work at end of word (unless last word)
Product: WebKit Reporter: Duncan Wilcox <duncan>
Component: HTML EditingAssignee: Dave Hyatt <hyatt>
Status: RESOLVED FIXED    
Severity: Normal CC: ap
Priority: P2    
Version: 420+   
Hardware: Mac   
OS: OS X 10.4   
Attachments:
Description Flags
test case
none
proposed patch (use rangeByAlteringCurrentSelection)
none
proposed patch (use rangeByAlteringCurrentSelection) darin: review+

Description Duncan Wilcox 2005-07-18 15:01:35 PDT
Pressing cmd+esc will invoke the webview complete: method, that will popup a list of words that 
complete the text typed so far.

This functionality only works if you hit cmd-esc after the last word on the page, or if you type cmd-esc 
while within a word. It doesn't work if you hit cmd-esc at the end of a word that is not the last one.

In the attached sample hit cmd-esc when the cursor is just after "one", you will get a NSBeep(). If you hit 
cmd-esc with the cursor after "three" it will work.

A rough guess is that this happens because -[WebTextCompleteController doCompletion] is calling 
[bridge rangeByExpandingSelectionWithGranularity:WebSelectByWord] that doesn't work when a space 
follows the cursor.

The spelling suggestion functionality appears to be filtered away by safari, so it's not testable with a 
plain web page.
Comment 1 Duncan Wilcox 2005-07-18 15:07:32 PDT
Created attachment 3007 [details]
test case

Create a cocoa app in xcode, replace main.m with the attachment and add the
WebKit.framework to the project.
Comment 2 Alexey Proskuryakov 2005-10-26 12:49:49 PDT
Confirmed with ToT (running Blot)
Comment 3 Alexey Proskuryakov 2005-10-27 12:12:48 PDT
Created attachment 4490 [details]
proposed patch (use rangeByAlteringCurrentSelection)

I have also thought about changing rangeByExpandingSelectionWithGranularity: to
work in this case, but this seems to require quite a number of changes to how a
selection's affinity is set in various places, which may or may not be
desirable...
Comment 4 Alexey Proskuryakov 2005-10-27 12:14:11 PDT
Created attachment 4491 [details]
proposed patch (use rangeByAlteringCurrentSelection)

An unrelated change sneaked into the patch...
Comment 5 Darin Adler 2005-10-27 21:47:12 PDT
Comment on attachment 4491 [details]
proposed patch (use rangeByAlteringCurrentSelection)

Looks fine. r=me