Skip to content

Fix parsing section lines with trailing comments #363

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ Hong Xu
10sr
Usami Kenta
Izaak "Zaak" Beekman
Ron Parker
2 changes: 1 addition & 1 deletion editorconfig-core-handle.el
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ If CONF is not found return nil."
nil)

;; Start of section
((looking-at "\\[\\(.*\\)\\][ \t]*$")
((looking-at "\\[\\(.*\\)\\][ \t]*\\(?:[#;].*\\)?$")
(let ((newpattern (match-string 1)))
(when pattern
(push (make-editorconfig-core-handle-section
Expand Down
6 changes: 5 additions & 1 deletion ert-tests/editorconfig-core-handle-tests.el
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,11 @@
(should (equal (editorconfig-core-handle-get-properties handle
(concat editorconfig--fixtures
"a.js"))
'((("key" . "value"))))))
'((("key" . "value")))))
(should (equal (editorconfig-core-handle-get-properties handle
(concat editorconfig--fixtures
"b.py"))
'((("key2" . "value2"))))))

;; For checking various normal whitespace (line breaks, horizontal space, vertical space, etc.)
(let* ((conf (concat default-directory
Expand Down
4 changes: 4 additions & 0 deletions ert-tests/fixtures/handle2.ini
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[a.js]

key = value

[b.py] # Section comment

key2 = value2