fmt: keep the shebang header in vsh files (#7893)
parent
2aea11e607
commit
eaba21d81a
|
@ -1355,6 +1355,10 @@ struct CommentsOptions {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
|
pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
|
||||||
|
if node.text.starts_with('#!') {
|
||||||
|
f.writeln(node.text)
|
||||||
|
return
|
||||||
|
}
|
||||||
if options.iembed {
|
if options.iembed {
|
||||||
x := node.text.trim_left('\x01')
|
x := node.text.trim_left('\x01')
|
||||||
if x.contains('\n') {
|
if x.contains('\n') {
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
#!/usr/local/bin/v run
|
||||||
|
|
||||||
|
x := 5
|
||||||
|
println(x)
|
|
@ -820,9 +820,9 @@ fn (mut s Scanner) text_scan() token.Token {
|
||||||
s.ignore_line()
|
s.ignore_line()
|
||||||
if nextc == `!` {
|
if nextc == `!` {
|
||||||
// treat shebang line (#!) as a comment
|
// treat shebang line (#!) as a comment
|
||||||
s.line_comment = s.text[start + 1..s.pos].trim_space()
|
comment := s.text[start - 1..s.pos].trim_space()
|
||||||
// s.fgenln('// shebang line "$s.line_comment"')
|
// s.fgenln('// shebang line "$s.line_comment"')
|
||||||
continue
|
return s.new_token(.comment, comment, comment.len + 2)
|
||||||
}
|
}
|
||||||
hash := s.text[start..s.pos].trim_space()
|
hash := s.text[start..s.pos].trim_space()
|
||||||
return s.new_token(.hash, hash, hash.len)
|
return s.new_token(.hash, hash, hash.len)
|
||||||
|
|
Loading…
Reference in New Issue