mirror of
https://github.com/mattn/emmet-vim.git
synced 2025-12-06 18:54:27 +08:00
Fix mergeLines()
This commit is contained in:
@@ -208,7 +208,6 @@ function! emmet#lang#html#parseIntoTree(abbr, type) abort
|
|||||||
let current.snippet = snippet
|
let current.snippet = snippet
|
||||||
break
|
break
|
||||||
elseif custom =~# k
|
elseif custom =~# k
|
||||||
let g:hoge = current
|
|
||||||
let snippet = '${' . custom . '}'
|
let snippet = '${' . custom . '}'
|
||||||
let current.snippet = '${' . custom . '}'
|
let current.snippet = '${' . custom . '}'
|
||||||
if current.name != ''
|
if current.name != ''
|
||||||
@@ -825,7 +824,7 @@ function! emmet#lang#html#balanceTag(flag) range abort
|
|||||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||||
endif
|
endif
|
||||||
let block = [pos1, pos2]
|
let block = [pos1, pos2]
|
||||||
if pos1[0] == 0 && pos1[1] == 0
|
if pos1 == [0, 0]
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block)
|
if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block)
|
||||||
@@ -858,7 +857,7 @@ function! emmet#lang#html#balanceTag(flag) range abort
|
|||||||
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||||
endif
|
endif
|
||||||
let block = [pos1, pos2]
|
let block = [pos1, pos2]
|
||||||
if pos1[0] == 0 && pos1[1] == 0
|
if pos1 == [0, 0]
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
if emmet#util#regionIsValid(block)
|
if emmet#util#regionIsValid(block)
|
||||||
@@ -976,29 +975,37 @@ endfunction
|
|||||||
|
|
||||||
function! emmet#lang#html#mergeLines() abort
|
function! emmet#lang#html#mergeLines() abort
|
||||||
let curpos = emmet#util#getcurpos()
|
let curpos = emmet#util#getcurpos()
|
||||||
let mx = '<\(/\{0,1}[a-zA-Z][-a-zA-Z0-9:_\-]*\)\%(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\s*\%(/\{0,1}\)>'
|
let settings = emmet#getSettings()
|
||||||
|
|
||||||
let pos1 = searchpos(mx, 'bcnW')
|
let mx = '<\([a-zA-Z][a-zA-Z0-9:_\-]*\)[^>]*>'
|
||||||
|
let last = curpos[1:2]
|
||||||
|
while 1
|
||||||
|
let pos1 = searchpos(mx, 'bcW')
|
||||||
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
let content = matchstr(getline(pos1[0])[pos1[1]-1:], mx)
|
||||||
let tag_name = substitute(content, '^<\(/\{0,1}[a-zA-Z][a-zA-Z0-9:_\-]*\).*$', '\1', '')
|
echomsg string(content)
|
||||||
let block = [pos1, [pos1[0], pos1[1] + len(content) - 1]]
|
let tag_name = matchstr(content, '^<\zs[a-zA-Z0-9:_\-]*\ze')
|
||||||
if content[-2:] ==# '/>' && emmet#util#cursorInRegion(block)
|
if stridx(','.settings.html.empty_elements.',', ','.tag_name.',') != -1
|
||||||
call setpos('.', [0, block[0][0], block[0][1], 0])
|
let pos2 = searchpos('>', 'nW')
|
||||||
return
|
|
||||||
endif
|
|
||||||
if tag_name[0] ==# '/'
|
|
||||||
let pos1 = searchpos('<' . tag_name[1:] . '[^a-zA-Z0-9]', 'bcnW')
|
|
||||||
call setpos('.', [0, pos1[0], pos1[1], 0])
|
|
||||||
let pos2 = searchpairpos('<'. tag_name[1:] . '\>[^/>]*>', '', '</' . tag_name[1:] . '>', 'W')
|
|
||||||
else
|
else
|
||||||
let pos2 = searchpairpos('<'. tag_name . '[^/>]*>', '', '</' . tag_name . '>', 'W')
|
let pos2 = searchpairpos('<' . tag_name . '[^>]*>', '', '</'. tag_name . '\zs>', 'nW')
|
||||||
endif
|
endif
|
||||||
if pos2 == [0, 0]
|
if pos1 == [0, 0] || pos2 == [0, 0]
|
||||||
|
call setpos('.', curpos)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
let pos2 = searchpos('>', 'neW')
|
|
||||||
let block = [pos1, pos2]
|
let block = [pos1, pos2]
|
||||||
|
if emmet#util#pointInRegion(last, block) && emmet#util#regionIsValid(block)
|
||||||
|
break
|
||||||
|
endif
|
||||||
|
if pos1 == last
|
||||||
|
call setpos('.', curpos)
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
let last = pos1
|
||||||
|
endwhile
|
||||||
|
|
||||||
let content = emmet#util#getContent(block)
|
let content = emmet#util#getContent(block)
|
||||||
|
let mx = '<\(/\{0,1}[a-zA-Z][-a-zA-Z0-9:_\-]*\)\%(\%(\s[a-zA-Z][a-zA-Z0-9]\+=\%([^"'' \t]\+\|"[^"]\{-}"\|''[^'']\{-}''\)\s*\)*\)\s*\%(/\{0,1}\)>'
|
||||||
let content = join(map(split(content, mx . '\zs\s*'), 'trim(v:val)'), '')
|
let content = join(map(split(content, mx . '\zs\s*'), 'trim(v:val)'), '')
|
||||||
call emmet#util#setContent(block, content)
|
call emmet#util#setContent(block, content)
|
||||||
if block[0][0] > 0
|
if block[0][0] > 0
|
||||||
|
|||||||
@@ -132,7 +132,8 @@ function! s:install_plugin(mode, buffer)
|
|||||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'},
|
\ {'mode': 'n', 'var': 'user_emmet_anchorizeurl_key', 'key': 'a', 'plug': 'emmet-anchorize-url', 'func': ':call emmet#anchorizeURL(0)<cr>'},
|
||||||
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'},
|
\ {'mode': 'i', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#anchorizeURL(1)<cr>'},
|
||||||
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
|
\ {'mode': 'n', 'var': 'user_emmet_anchorizesummary_key', 'key': 'A', 'plug': 'emmet-anchorize-summary', 'func': ':call emmet#anchorizeURL(1)<cr>'},
|
||||||
\ {'mode': 'v', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'},
|
\ {'mode': 'i', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': '<c-r>=emmet#util#closePopup()<cr><c-r>=emmet#mergeLines()<cr>'},
|
||||||
|
\ {'mode': 'n', 'var': 'user_emmet_mergelines_key', 'key': 'm', 'plug': 'emmet-merge-lines', 'func': ':call emmet#mergeLines()<cr>'},
|
||||||
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'},
|
\ {'mode': 'v', 'var': 'user_emmet_codepretty_key', 'key': 'c', 'plug': 'emmet-code-pretty', 'func': ':call emmet#codePretty()<cr>'},
|
||||||
\]
|
\]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user