vet: remove false positive space indentation error inside block comments (#9565)
parent
1bb48c3577
commit
e438b158a6
|
@ -1,2 +1,3 @@
|
|||
cmd/tools/vvet/tests/indent_with_space.vv:2: error: Looks like you are using spaces for indentation.
|
||||
cmd/tools/vvet/tests/indent_with_space.vv:10: error: Looks like you are using spaces for indentation.
|
||||
NB: You can run `v fmt -w file.v` to fix these errors automatically
|
||||
|
|
|
@ -1,3 +1,13 @@
|
|||
fn main() {
|
||||
_ = 1 == 2
|
||||
}
|
||||
|
||||
fn block_comments() {
|
||||
/* tab to indent the comment
|
||||
spaces before
|
||||
also spaces before
|
||||
same here */
|
||||
/* spaces for comment indentation (ouch)
|
||||
and inside too
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -216,8 +216,8 @@ pub fn parse_vet_file(path string, table_ &ast.Table, pref &pref.Preferences) (a
|
|||
}
|
||||
}
|
||||
}
|
||||
file := p.parse()
|
||||
p.vet_errors << p.scanner.vet_errors
|
||||
file := p.parse()
|
||||
return file, p.vet_errors
|
||||
}
|
||||
|
||||
|
@ -614,9 +614,14 @@ pub fn (mut p Parser) comment() ast.Comment {
|
|||
text := p.tok.lit
|
||||
pos.last_line = pos.line_nr + text.count('\n')
|
||||
p.next()
|
||||
// p.next_with_comment()
|
||||
is_multi := text.contains('\n')
|
||||
// Filter out space indentation vet errors inside block comments
|
||||
if p.vet_errors.len > 0 && is_multi {
|
||||
p.vet_errors = p.vet_errors.filter(!(it.pos.line_nr - 1 > pos.line_nr
|
||||
&& it.pos.line_nr - 1 <= pos.last_line))
|
||||
}
|
||||
return ast.Comment{
|
||||
is_multi: text.contains('\n')
|
||||
is_multi: is_multi
|
||||
text: text
|
||||
pos: pos
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue