cmd/tools/v/vdoc: keep `_` sep in numeric literals and highlight modules properly (#9358)

pull/9352/head
Swastik Baranwal 2021-03-18 18:36:16 +05:30 committed by GitHub
parent eccf707270
commit f28e67d526
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -189,7 +189,7 @@ fn color_highlight(code string, tb &table.Table) string {
} }
return lit return lit
} }
mut s := scanner.new_scanner(code, .parse_comments, &pref.Preferences{}) mut s := scanner.new_scanner(code, .parse_comments, &pref.Preferences{ is_fmt: true })
mut prev_prev := token.Token{} mut prev_prev := token.Token{}
mut prev := token.Token{} mut prev := token.Token{}
mut tok := s.scan() mut tok := s.scan()
@ -214,9 +214,13 @@ fn color_highlight(code string, tb &table.Table) string {
} else if next_tok.kind == .dot { } else if next_tok.kind == .dot {
if tok.lit in ['C', 'JS'] { if tok.lit in ['C', 'JS'] {
tok_typ = .prefix tok_typ = .prefix
} else {
if tok.lit[0].ascii_str().is_upper() {
tok_typ = .symbol
} else { } else {
tok_typ = .module_ tok_typ = .module_
} }
}
} else if tok.lit in ['r', 'c'] && next_tok.kind == .string { } else if tok.lit in ['r', 'c'] && next_tok.kind == .string {
tok_typ = .prefix tok_typ = .prefix
} else { } else {

View File

@ -100,6 +100,7 @@ pub fn new_vdoc_preferences() &pref.Preferences {
// so its preferences should be permissive: // so its preferences should be permissive:
return &pref.Preferences{ return &pref.Preferences{
enable_globals: true enable_globals: true
is_fmt: true
} }
} }