File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1113,7 +1113,7 @@ endfunction
11131113
11141114function ! sj#ruby#JoinOnelineDef ()
11151115 " 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
11171117 return 0
11181118 endif
11191119
Original file line number Diff line number Diff line change @@ -1901,5 +1901,47 @@ def foo(one, two)
19011901 def foo(one, two) = bar
19021902 EOF
19031903 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
19041946 end
19051947end
You can’t perform that action at this time.
0 commit comments