| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -144,19 +144,28 @@ function! s:IsPosInClassDef(pos) | |||
| 144 | 144 | return ret | |
| 145 | 145 | endfunction | |
| 146 | 146 | ||
| 147 | + function! s:IsInComment(pos) | ||
| 148 | + let stack = synstack(a:pos[0], a:pos[1]) | ||
| 149 | + if !empty(stack) | ||
| 150 | + return synIDattr(stack[0], 'name') =~ 'ruby\%(.*Comment\|Documentation\)' | ||
| 151 | + else | ||
| 152 | + return 0 | ||
| 153 | + endif | ||
| 154 | + endfunction | ||
| 155 | + | ||
| 147 | 156 | function! s:GetRubyVarType(v) | |
| 148 | 157 | let stopline = 1 | |
| 149 | 158 | let vtp = '' | |
| 150 | - let pos = getpos('.') | ||
| 159 | + let curpos = getpos('.') | ||
| 151 | 160 | let sstr = '^\s*#\s*@var\s*'.escape(a:v, '*').'\>\s\+[^ \t]\+\s*$' | |
| 152 | 161 | let [lnum,lcol] = searchpos(sstr,'nb',stopline) | |
| 153 | 162 | if lnum != 0 && lcol != 0 | |
| 154 | - call setpos('.',pos) | ||
| 163 | + call setpos('.',curpos) | ||
| 155 | 164 | let str = getline(lnum) | |
| 156 | 165 | let vtp = substitute(str,sstr,'\1','') | |
| 157 | 166 | return vtp | |
| 158 | 167 | endif | |
| 159 | - call setpos('.',pos) | ||
| 168 | + call setpos('.',curpos) | ||
| 160 | 169 | let ctors = '\(now\|new\|open\|get_instance' | |
| 161 | 170 | if exists('g:rubycomplete_rails') && g:rubycomplete_rails == 1 && s:rubycomplete_rails_loaded == 1 | |
| 162 | 171 | let ctors = ctors.'\|find\|create' | |
@@ -166,9 +175,13 @@ function! s:GetRubyVarType(v) | |||
| 166 | 175 | ||
| 167 | 176 | let fstr = '=\s*\([^ \t]\+.' . ctors .'\>\|[\[{"''/]\|%[xwQqr][(\[{@]\|[A-Za-z0-9@:\-()\.]\+...\?\|lambda\|&\)' | |
| 168 | 177 | let sstr = ''.escape(a:v, '*').'\>\s*[+\-*/]*'.fstr | |
| 169 | - let [lnum,lcol] = searchpos(sstr,'nb',stopline) | ||
| 170 | - if lnum != 0 && lcol != 0 | ||
| 171 | - let str = matchstr(getline(lnum),fstr,lcol) | ||
| 178 | + let pos = searchpos(sstr,'bW') | ||
| 179 | + while pos != [0,0] && s:IsInComment(pos) | ||
| 180 | + let pos = searchpos(sstr,'bW') | ||
| 181 | + endwhile | ||
| 182 | + if pos != [0,0] | ||
| 183 | + let [lnum, col] = pos | ||
| 184 | + let str = matchstr(getline(lnum),fstr,col) | ||
| 172 | 185 | let str = substitute(str,'^=\s*','','') | |
| 173 | 186 | ||
| 174 | 187 | call setpos('.',pos) | |
@@ -190,7 +203,7 @@ function! s:GetRubyVarType(v) | |||
| 190 | 203 | end | |
| 191 | 204 | return '' | |
| 192 | 205 | endif | |
| 193 | - call setpos('.',pos) | ||
| 206 | + call setpos('.',curpos) | ||
| 194 | 207 | return '' | |
| 195 | 208 | endfunction | |
| 196 | 209 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments