@@ -155,20 +155,39 @@ endfunction
155155function ! s: Alternate (cmd) abort
156156 let l: currentpath = expand (' %' )
157157 let l: possiblepathsforalternatefile = []
158+
158159 for possiblenewpath in [s: SubStr (l: currentpath , " .js" , " _test.js" ), s: SubStr (l: currentpath , " _test.js" , " .js" )]
159160 if possiblenewpath != l: currentpath
160- let l: possiblepathsforalternatefile = [possiblenewpath]
161+ let l: possiblepathsforalternatefile = l: possiblepathsforalternatefile + [possiblenewpath]
161162 endif
162163 endfor
163164
165+ " handle a test subdirectory just above the leaf node
166+ let l: possiblenewpath = s: SubStr (l: currentpath , " /test/" , " /" )
167+ if possiblenewpath != l: currentpath
168+ let l: possiblepathsforalternatefile = l: possiblepathsforalternatefile + [s: SubStr (possiblenewpath, ' .spec.js' , ' .js' )]
169+ else
170+ let l: lastslashindex = strridx (l: currentpath , ' /' )
171+ let l: possibletestpath = strpart (l: currentpath , 0 , l: lastslashindex ) . ' /test' . s: SubStr (strpart (l: currentpath , l: lastslashindex ), ' .js' , ' .spec.js' )
172+ let l: possiblepathsforalternatefile = l: possiblepathsforalternatefile + [l: possibletestpath ]
173+ endif
174+
164175 if exists (' g:angular_source_directory' )
165- let l: possiblesrcpaths = [g: angular_source_directory ]
176+ if type (g: angular_source_directory ) == type ([])
177+ let l: possiblesrcpaths = g: angular_source_directory
178+ else
179+ let l: possiblesrcpaths = [g: angular_source_directory ]
180+ endif
166181 else
167182 let l: possiblesrcpaths = [' app/src' , ' app/js' , ' app/scripts' , ' public/js' , ' frontend/src' ]
168183 endif
169184
170185 if exists (' g:angular_test_directory' )
171- let l: possibletestpaths = [g: angular_test_directory ]
186+ if type (g: angular_test_directory ) == type ([])
187+ let l: possibletestpaths = g: angular_test_directory
188+ else
189+ let l: possibletestpaths = [g: angular_test_directory ]
190+ endif
172191 else
173192 let l: possibletestpaths = [' test/unit' , ' test/spec' , ' test/karma/unit' , ' tests/frontend' ]
174193 endif
0 commit comments