Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autoload/ghcmod/command.vim
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ endfunction "}}}

function! ghcmod#command#type(force) "{{{
let l:line = line('.')
let l:col = col('.')
let l:col = ghcmod#util#getcol()

if exists('b:ghcmod_type')
if b:ghcmod_type.spans(l:line, l:col)
Expand Down Expand Up @@ -69,7 +69,7 @@ function! ghcmod#command#type_insert(force) "{{{
endif

let l:module = ghcmod#detect_module()
let l:types = ghcmod#type(line('.'), col('.'), l:path, l:module)
let l:types = ghcmod#type(line('.'), ghcmod#util#getcol(), l:path, l:module)
if empty(l:types) " Everything failed so let's just abort
call ghcmod#util#print_error('ghcmod#command#type_insert: Cannot guess type')
return
Expand Down
2 changes: 2 additions & 0 deletions autoload/ghcmod/type.vim
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ function! s:ghcmod_type.highlight() "{{{
endif
call self.clear_highlight()
let [l:line1, l:col1, l:line2, l:col2] = self.types[self.ix][0]
let l:col1 = ghcmod#util#tocol(l:line1, l:col1)
let l:col2 = ghcmod#util#tocol(l:line2, l:col2)
let self.match_id = matchadd(self.group, '\%' . l:line1 . 'l\%' . l:col1 . 'c\_.*\%' . l:line2 . 'l\%' . l:col2 . 'c')
endfunction "}}}

Expand Down
20 changes: 20 additions & 0 deletions autoload/ghcmod/util.vim
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ function! ghcmod#util#join_path(dir, path) "{{{
endif
endfunction "}}}

function! ghcmod#util#getcol() "{{{
let l:line = line('.')
let l:col = col('.')
let l:str = getline(l:line)[:(l:col - 1)]
let l:tabcnt = len(substitute(l:str, '[^\t]', '', 'g'))
return l:col + 7 * l:tabcnt
endfunction "}}}

function! ghcmod#util#tocol(line, col) "{{{
let l:str = getline(a:line)
let l:col = 0
for l:i in range(1, len(l:str))
let l:col += (l:str[l:i - 1] ==# "\t" ? 8 : 1)
if l:col >= a:col
return l:i
endif
endfor
return l:i + 1
endfunction "}}}

function! ghcmod#util#wait(proc) "{{{
if has_key(a:proc, 'checkpid')
return a:proc.checkpid()
Expand Down