forked from VimPlug/emmet-vim
use region util.
This commit is contained in:
@@ -1354,28 +1354,11 @@ function! s:zen_parseTag(tag)
|
|||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:zen_imageSize()
|
function! s:zen_imageSize()
|
||||||
let line = getline('.')
|
let img_region = s:search_region('<img\s', '>')
|
||||||
let mx = '<img [^>]\+>'
|
if !s:region_is_valid(img_region) || !s:cursor_in_region(img_region)
|
||||||
let c = 0
|
|
||||||
let match = ''
|
|
||||||
while len(line)
|
|
||||||
let match = matchstr(line, mx)
|
|
||||||
if len(match) == 0
|
|
||||||
let c = -1
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let pos = stridx(line, match)
|
|
||||||
let c += pos
|
|
||||||
if c <= col('.') && (col('.') < c + len(match))
|
|
||||||
break
|
|
||||||
endif
|
|
||||||
let line = line[pos + len(match):]
|
|
||||||
let c += len(match)
|
|
||||||
endwhile
|
|
||||||
if c == -1 || len(line) == 0
|
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let current = s:zen_parseTag(match)
|
let current = s:zen_parseTag(s:get_content(img_region))
|
||||||
let fn = current.attr['src']
|
let fn = current.attr['src']
|
||||||
let [w, h] = [-1, -1]
|
let [w, h] = [-1, -1]
|
||||||
|
|
||||||
@@ -1409,9 +1392,7 @@ EOF
|
|||||||
let current.attr['width'] = w
|
let current.attr['width'] = w
|
||||||
let current.attr['height'] = h
|
let current.attr['height'] = h
|
||||||
let html = s:zen_toString(current, 'html', 1)
|
let html = s:zen_toString(current, 'html', 1)
|
||||||
let line = getline('.')
|
call s:change_content(img_region, html)
|
||||||
let line = line[:c-1] . html . line[c + len(match):]
|
|
||||||
call setline(line('.'), line)
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:zen_toggleComment()
|
function! s:zen_toggleComment()
|
||||||
|
|||||||
Reference in New Issue
Block a user