Skip to content

Commit 25f5a77

Browse files
committed
fix: don't error on continuation characters
1 parent 44c18b3 commit 25f5a77

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

internal/lint/util.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ func findBestLineBySubstring(s, sub string) (int, string) {
3636
}
3737

3838
func findLineBySubstring(s, sub string, seen map[string]int) (int, string) {
39-
if strings.Count(sub, "\n") > 0 {
39+
lines := strings.Count(sub, "\n")
40+
if lines > 0 {
4041
sub = strings.Split(sub, "\n")[0]
4142
}
4243

@@ -48,6 +49,21 @@ func findLineBySubstring(s, sub string, seen map[string]int) (int, string) {
4849
}
4950
}
5051

52+
if lines <= 0 {
53+
// Special case: check for substrings.
54+
//
55+
// See #1018.
56+
for _, part := range strings.Split(sub, " ") {
57+
for i, line := range strings.Split(s, "\n") {
58+
if strings.Contains(line, part) {
59+
if j, ok := seen[line]; !ok || j-1 != i {
60+
return i + 1, line
61+
}
62+
}
63+
}
64+
}
65+
}
66+
5167
return -1, ""
5268
}
5369

testdata/fixtures/views/.vale.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,6 @@ View = Petstore
2525

2626
[Rule.yml]
2727
View = Vale
28+
29+
[newline.yml]
30+
View = NewLine
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
openapi: 3.0.1
2+
info:
3+
description: "Line 1\
4+
\ Line 2"
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
engine: dasel
2+
scopes:
3+
# API info
4+
- expr: info.description
5+
name: title

0 commit comments

Comments
 (0)