summaryrefslogtreecommitdiff
path: root/runtime/menu.vim
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-07-10 16:36:59 +0200
committerBram Moolenaar <Bram@vim.org>2010-07-10 16:36:59 +0200
commit622925875cb9d7f04a764ed8e002e45c3a141e94 (patch)
tree93ae71a2e76b31a927953bb0735f649fb51d6702 /runtime/menu.vim
parent9c754c4542066bbdf608738b36cf8878dbfd61d6 (diff)
downloadvim-git-622925875cb9d7f04a764ed8e002e45c3a141e94.tar.gz
Fix bug: spell menu moved cursor, causing Copy not to work. Spell replacement
didn't work in 'compatible' mode.
Diffstat (limited to 'runtime/menu.vim')
-rw-r--r--runtime/menu.vim12
1 files changed, 8 insertions, 4 deletions
diff --git a/runtime/menu.vim b/runtime/menu.vim
index 5b5246507..a9eb81879 100644
--- a/runtime/menu.vim
+++ b/runtime/menu.vim
@@ -901,7 +901,6 @@ if has("spell")
let [w, a] = spellbadword()
if col('.') > curcol " don't use word after the cursor
let w = ''
- call cursor(0, curcol) " put the cursor back where it was
endif
if w != ''
if a == 'caps'
@@ -909,12 +908,13 @@ if has("spell")
else
let s:suglist = spellsuggest(w, 10)
endif
- if len(s:suglist) <= 0
- call cursor(0, curcol) " put the cursor back where it was
- else
+ if len(s:suglist) > 0
let s:changeitem = 'change\ "' . escape(w, ' .'). '"\ to'
let s:fromword = w
let pri = 1
+ " set 'cpo' to include the <CR>
+ let cpo_save = &cpo
+ set cpo&vim
for sug in s:suglist
exe 'anoremenu 1.5.' . pri . ' PopUp.' . s:changeitem . '.' . escape(sug, ' .')
\ . ' :call <SID>SpellReplace(' . pri . ')<CR>'
@@ -928,12 +928,16 @@ if has("spell")
exe 'anoremenu 1.7 PopUp.' . s:ignoreitem . ' :spellgood! ' . w . '<CR>'
anoremenu 1.8 PopUp.-SpellSep- :
+ let &cpo = cpo_save
endif
endif
+ call cursor(0, curcol) " put the cursor back where it was
endfunc
func! <SID>SpellReplace(n)
let l = getline('.')
+ " Move the cursor to the start of the word.
+ call spellbadword()
call setline('.', strpart(l, 0, col('.') - 1) . s:suglist[a:n - 1]
\ . strpart(l, col('.') + len(s:fromword) - 1))
endfunc