Commits

Tamas Kovacs committed 4970e3e

Do not insert newline if item is selected in completion popup menu by pressing <CR>
No matter if Electric or Regular Return method is used

Comments (0)

Files changed (2)

ftplugin/slimv.vim

 " slimv.vim:    The Superior Lisp Interaction Mode for VIM
 " Version:      0.9.11
-" Last Change:  09 Aug 2013
+" Last Change:  10 Aug 2013
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 function! SlimvHandleEnter()
     let s:arglist_line = line('.')
     let s:arglist_col = col('.')
-    if exists( 'g:paredit_mode' ) && g:paredit_mode && g:paredit_electric_return
-        return PareditEnter()
+    if pumvisible()
+        " Pressing <CR> in a pop up selects entry.
+        return "\<C-Y>"
     else
-        return "\<CR>"
+        if exists( 'g:paredit_mode' ) && g:paredit_mode && g:paredit_electric_return
+            " Apply electric return
+            return PareditEnter()
+        else
+            " No electric return handling, just enter a newline
+            return "\<CR>"
+        endif
     endif
 endfunction
 
         " Command part before cursor is unbalanced, insert newline
         let s:arglist_line = line('.')
         let s:arglist_col = col('.')
-        if exists( 'g:paredit_mode' ) && g:paredit_mode && g:paredit_electric_return && lastline > 0 && line( "." ) >= lastline
-            " Apply electric return
-            return PareditEnter()
+        if pumvisible()
+            " Pressing <CR> in a pop up selects entry.
+            return "\<C-Y>"
         else
-            " No electric return handling, just enter a newline
-            return "\<CR>"
+            if exists( 'g:paredit_mode' ) && g:paredit_mode && g:paredit_electric_return && lastline > 0 && line( "." ) >= lastline
+                " Apply electric return
+                return PareditEnter()
+            else
+                " No electric return handling, just enter a newline
+                return "\<CR>"
+            endif
         endif
     else
         " Send current command line for evaluation

plugin/paredit.vim

 " paredit.vim:
 "               Paredit mode for Slimv
 " Version:      0.9.11
-" Last Change:  20 Jul 2013
+" Last Change:  10 Aug 2013
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 
 " Handle <Enter> keypress, insert electric return if applicable
 function! PareditEnter()
-    let line = getline( '.' )
-    let pos = col( '.' ) - 1
-    if g:paredit_electric_return && pos > 0 && line[pos] =~ b:any_closing_char && !s:InsideString() && s:IsBalanced()
-        " Electric Return
-        if pumvisible()
-            " Pressing <CR> in a pop up selects entry.
-            return "\<C-Y>"
+    if pumvisible()
+        " Pressing <CR> in a pop up selects entry.
+        return "\<C-Y>"
+    else
+        let line = getline( '.' )
+        let pos = col( '.' ) - 1
+        if g:paredit_electric_return && pos > 0 && line[pos] =~ b:any_closing_char && !s:InsideString() && s:IsBalanced()
+            " Electric Return
+            return "\<CR>\<CR>\<Up>"
         else
-            return "\<CR>\<CR>\<Up>"
+            " Regular Return
+            return "\<CR>"
         endif
-    else
-        " Regular Return
-        return "\<CR>"
     endif
 endfunction