Skip to content

Commit 22185c4

Browse files
pizkazSebastian NeuserSebastian Neuser
authored
Remove ANSI color codes from nix linter messages (#4944)
* Remove ANSI color codes from nix linter messages * Add test for color-coded nix linter findings * Fix test: Escape backslashes --------- Co-authored-by: Sebastian Neuser <sebastian.neuser@fnordkollektiv.de> Co-authored-by: Sebastian Neuser <haggl@sineband.de>
1 parent 2883260 commit 22185c4

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

ale_linters/nix/nix.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ function! ale_linters#nix#nix#Handle(buffer, lines) abort
2929
\ 'type': 'E',
3030
\ 'lnum': l:result.line,
3131
\ 'col': l:result.column,
32-
\ 'text': l:result.raw_msg
32+
\ 'text': substitute(l:result.raw_msg, '\e\[[0-9;]*m', '', 'g'),
3333
\})
3434
endif
3535
endif

test/handler/test_nix_handler.vader

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,22 @@ Execute(The nix handler should parse nix-instantiate error messages correctly):
2727
\ "@nix {\"unrelated\":\"message\"}"
2828
\ ])
2929

30+
Execute(The nix handler should parse nix-instantiate error messages with ANSI color codes correctly):
31+
AssertEqual
32+
\ [
33+
\ {
34+
\ 'lnum': 3,
35+
\ 'col': 5,
36+
\ 'type': 'E',
37+
\ 'text': "undefined variable 'foo'",
38+
\ },
39+
\
40+
\ ],
41+
\ ale_linters#nix#nix#Handle(bufnr(''), [
42+
\ "@nix {\"line\":3,\"column\":5,\"raw_msg\":\"undefined variable '\\u001b[35;1mfoo\\u001b[0m'\"}",
43+
\ "@nix {\"unrelated\":\"message\"}"
44+
\ ])
45+
3046
Execute(The nix handler should parse message from old nix-instantiate correctly):
3147
AssertEqual
3248
\ [

0 commit comments

Comments
 (0)