File tree 2 files changed +43
-1
lines changed
2 files changed +43
-1
lines changed Original file line number Diff line number Diff line change @@ -1113,7 +1113,7 @@ endfunction
1113
1113
1114
1114
function ! sj#ruby#JoinOnelineDef ()
1115
1115
" adapted from vim-ruby
1116
- if search (' \<def\s\+\%(\k\+\.\)\=\k\+[!?]\=\%((.*)\)\s*\%(#.*\)\=$' , ' Wbc' , line (' .' )) <= 0
1116
+ if search (' \<def\s\+\%(\k\+\.\)\=\k\+[!?]\=\s*\ %((.*)\)\= \s*\%(#.*\)\=$' , ' Wbc' , line (' .' )) <= 0
1117
1117
return 0
1118
1118
endif
1119
1119
Original file line number Diff line number Diff line change @@ -1901,5 +1901,47 @@ def foo(one, two)
1901
1901
def foo(one, two) = bar
1902
1902
EOF
1903
1903
end
1904
+
1905
+ specify "with the cursor on a definition without arguments" do
1906
+ set_file_contents <<~EOF
1907
+ def foo = bar
1908
+ EOF
1909
+
1910
+ vim . search 'def'
1911
+ split
1912
+
1913
+ assert_file_contents <<~EOF
1914
+ def foo
1915
+ bar
1916
+ end
1917
+ EOF
1918
+
1919
+ join
1920
+
1921
+ assert_file_contents <<~EOF
1922
+ def foo = bar
1923
+ EOF
1924
+ end
1925
+
1926
+ specify "with the cursor on a definition arguments defaults" do
1927
+ set_file_contents <<~EOF
1928
+ def self.foo(bar = quux(42), ...) = bar
1929
+ EOF
1930
+
1931
+ vim . search 'def'
1932
+ split
1933
+
1934
+ assert_file_contents <<~EOF
1935
+ def self.foo(bar = quux(42), ...)
1936
+ bar
1937
+ end
1938
+ EOF
1939
+
1940
+ join
1941
+
1942
+ assert_file_contents <<~EOF
1943
+ def self.foo(bar = quux(42), ...) = bar
1944
+ EOF
1945
+ end
1904
1946
end
1905
1947
end
You can’t perform that action at this time.
0 commit comments