From c2cf315a05388dc2723046e69c1e7c76510107db Mon Sep 17 00:00:00 2001 From: mattn Date: Wed, 30 May 2012 21:36:59 +0900 Subject: [PATCH] fix toggleComment for css. --- autoload/zencoding/lang/css.vim | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/autoload/zencoding/lang/css.vim b/autoload/zencoding/lang/css.vim index 227171a..c5fd005 100644 --- a/autoload/zencoding/lang/css.vim +++ b/autoload/zencoding/lang/css.vim @@ -63,13 +63,27 @@ endfunction function! zencoding#lang#css#toggleComment() let line = getline('.') let mx = '^\(\s*\)/\*\s*\(.*\)\s*\*/\s*$' - if line =~ mx - let space = substitute(matchstr(line, mx), mx, '\1', '') - let line = substitute(matchstr(line, mx), mx, '\2', '') - let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g') + if line =~ '{\s*$' + let block = zencoding#util#searchRegion('/\*', '\*/\zs') + if zencoding#util#regionIsValid(block) + let content = zencoding#util#getContent(block) + let content = substitute(content, '/\*\s\(.*\)\s\*/', '\1', '') + call zencoding#util#setContent(block, content) + else + let node = expand('') + if len(node) + exe "normal ciw\='/* '.node.' */'\" + endif + endif else - let mx = '^\(\s*\)\(.*\)\s*$' - let line = substitute(line, mx, '\1/* \2 */', '') + if line =~ mx + let space = substitute(matchstr(line, mx), mx, '\1', '') + let line = substitute(matchstr(line, mx), mx, '\2', '') + let line = space . substitute(line, '^\s*\|\s*$', '\1', 'g') + else + let mx = '^\(\s*\)\(.*\)\s*$' + let line = substitute(line, mx, '\1/* \2 */', '') + endif + call setline('.', line) endif - call setline('.', line) endfunction