diff options
| author | Phil Crosby | 2009-12-06 00:54:53 -0800 |
|---|---|---|
| committer | Phil Crosby | 2009-12-06 00:54:53 -0800 |
| commit | bdaa3fc11ce6b836959fd7817fe04128d38b601b (patch) | |
| tree | 51e5dbf9452e379a212636c1a59223d4c7962c21 /linkHints.js | |
| parent | 88d8247dc79f082ca6215670fbe512500cc8fb36 (diff) | |
| download | vimium-bdaa3fc11ce6b836959fd7817fe04128d38b601b.tar.bz2 | |
Put the cursor at the end of the text field when selecting it via link hints. Fixes #19.
Diffstat (limited to 'linkHints.js')
| -rw-r--r-- | linkHints.js | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/linkHints.js b/linkHints.js index fdafa1ed..d3f6f14b 100644 --- a/linkHints.js +++ b/linkHints.js @@ -154,11 +154,15 @@ function updateLinkHints() { deactivateLinkHintsMode(); else if (linksMatched.length == 1) { var matchedLink = linksMatched[0]; - // Don't navigate to the selected link immediately; we want to give the user some feedback depicting - // which link they've selected by focusing it. Note that for textareas and inputs, the click - // event is ignored, but focus causes the desired behavior. - setTimeout(function() { simulateClick(matchedLink); }, 600); - matchedLink.focus(); + if (isInputOrText(matchedLink)) { + matchedLink.focus(); + matchedLink.setSelectionRange(matchedLink.value.length, matchedLink.value.length); + } else { + // Don't navigate to the selected link immediately; we want to give the user some feedback depicting + // which link they've selected by focusing it. + setTimeout(function() { simulateClick(matchedLink); }, 400); + matchedLink.focus(); + } deactivateLinkHintsMode(); } } |
