Skip to content

Commit 7fd3483

Browse files
committed
Try native JSON parsing
1 parent 8b77ce1 commit 7fd3483

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

autoload/rails.vim

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4441,8 +4441,11 @@ endfunction
44414441
" Projections {{{1
44424442

44434443
function! rails#json_parse(string) abort
4444-
let [null, false, true] = ['', 0, 1]
44454444
let string = type(a:string) == type([]) ? join(a:string, ' ') : a:string
4445+
if exists('*json_decode')
4446+
return json_decode(string)
4447+
endif
4448+
let [null, false, true] = ['', 0, 1]
44464449
let stripped = substitute(string,'\C"\(\\.\|[^"\\]\)*"','','g')
44474450
if stripped !~# "[^,:{}\\[\\]0-9.\\-+Eaeflnr-u \n\r\t]"
44484451
try
@@ -4947,8 +4950,10 @@ function! s:SetBasePath() abort
49474950
let path += get(g:, 'rails_path', [])
49484951
let path += ['app/models/concerns', 'app/controllers/concerns', 'app/controllers', 'app/helpers', 'app/mailers', 'app/models']
49494952

4953+
let true = get(v:, 'true', 1)
49504954
for [key, projection] in items(self.app().projections())
4951-
if get(projection, 'path', 0) is 1 || get(projection, 'autoload', 0) is 1
4955+
if get(projection, 'path', 0) is true || get(projection, 'autoload', 0) is true
4956+
\ || get(projection, 'path', 0) is 1 || get(projection, 'autoload', 0) is 1
49524957
let path += split(key, '*')[0]
49534958
endif
49544959
endfor

0 commit comments

Comments
 (0)