mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: keep the shebang header in vsh files (#7893)
This commit is contained in:
parent
2aea11e607
commit
eaba21d81a
@ -1355,6 +1355,10 @@ struct 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 {
|
||||
x := node.text.trim_left('\x01')
|
||||
if x.contains('\n') {
|
||||
|
4
vlib/v/fmt/tests/vscript_keep.vv
Normal file
4
vlib/v/fmt/tests/vscript_keep.vv
Normal file
@ -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()
|
||||
if nextc == `!` {
|
||||
// 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"')
|
||||
continue
|
||||
return s.new_token(.comment, comment, comment.len + 2)
|
||||
}
|
||||
hash := s.text[start..s.pos].trim_space()
|
||||
return s.new_token(.hash, hash, hash.len)
|
||||
|
Loading…
Reference in New Issue
Block a user