This repository was archived by the owner on Mar 27, 2023. It is now read-only.
File tree 2 files changed +25
-12
lines changed
2 files changed +25
-12
lines changed Original file line number Diff line number Diff line change @@ -8,16 +8,6 @@ function! AddParameter()
8
8
return
9
9
endtry
10
10
11
- " brackets
12
- if g: ruby_refactoring_brackets_have_space == 1
13
- let bracket_open = " ( "
14
- let bracket_close = " )"
15
- else
16
- let bracket_open = " ("
17
- let bracket_close = " )"
18
- endif
19
-
20
-
21
11
" Save current position
22
12
let cursor_position = getpos (" ." )
23
13
@@ -30,6 +20,15 @@ function! AddParameter()
30
20
" remove trailing whitespace
31
21
s /\v\s$/ /e
32
22
23
+ " brackets
24
+ if g: ruby_refactoring_brackets_have_space == 1
25
+ let bracket_open = " ( "
26
+ let bracket_close = " )"
27
+ else
28
+ let bracket_open = " ("
29
+ let bracket_close = " )"
30
+ endif
31
+
33
32
" test the line
34
33
let line = getline (" ." )
35
34
Original file line number Diff line number Diff line change 1
-
2
1
" Synopsis:
3
2
" Adds a parameter (or many separated with commas) to a method with no
4
3
" brackets
@@ -19,7 +18,22 @@ function! AddParameterNB()
19
18
exec " ?\\ <def\\ >"
20
19
endif
21
20
22
- execute " normal A " . name . " \<Esc> "
21
+ " remove trailing whitespace
22
+ s /\v\s$/ /e
23
+
24
+ " remove brackets
25
+ s /\v\s*\( ?/ /e
26
+ s /\v\s*\)/ /e
27
+
28
+ " test the line
29
+ let has_parameter = match (getline (" ." ), " \\ vdef \\ S+\\ s+\\ S+" )
30
+
31
+
32
+ if has_parameter != -1
33
+ exec " normal A, " . name . " \<Esc> "
34
+ else
35
+ exec " normal A " . name . " \<Esc> "
36
+ endif
23
37
24
38
" Restore caret position
25
39
call setpos (" ." , cursor_position)
You can’t perform that action at this time.
0 commit comments