aboutsummaryrefslogtreecommitdiffstats
path: root/community/vim-editorconfig/fix-config-parsing.patch
blob: 806407d40562e1559723c06ea7fdf333bd792cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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 "}}}
 
--