aports/community/vim-editorconfig/fix-config-parsing.patch
2017-10-23 19:11:50 +02:00

47 lines
1.1 KiB
Diff

From 69f86d1077b226a7535b1dec06d5bbf0fb2a89cd Mon Sep 17 00:00:00 2001
From: Jakub Jirutka <jakub@jirutka.cz>
Date: Mon, 23 Oct 2017 18:23:33 +0200
Subject: [PATCH] Fix trimming of empty comments
For example this .editorconfig:
```
; Lorem ipsum
;
; dolor sit amet
root = true
```
is parsed incorrectly:
s:parse_properties(...) -> [], {}
s:trim(...) -> [';', 'root = true']
s:remove_comment(';') -> ';'
This commit fixes this issue.
Patch-Source: https://github.com/sgur/vim-editorconfig/pull/15
---
autoload/editorconfig.vim | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/autoload/editorconfig.vim b/autoload/editorconfig.vim
index b0e4240..469172d 100644
--- a/autoload/editorconfig.vim
+++ b/autoload/editorconfig.vim
@@ -203,9 +203,11 @@ endfunction "}}}
"
" >>> echo s:remove_comment('bar')
" bar
+" >>> echo s:remove_comment('#')
+"
function! s:remove_comment(line) abort "{{{
- let pos = match(a:line, '\s*[;#].\+')
+ let pos = match(a:line, '\s*[;#].*')
return pos == -1 ? a:line : pos == 0 ? '' : a:line[: pos-1]
endfunction "}}}
--