fmt: fix formating a file in an oscillating manner (fix #22223, fix #22026) (#22232)

This commit is contained in:
yuyi 2024-09-17 14:47:38 +08:00 committed by GitHub
parent c004d0c899
commit acf6b344f7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
99 changed files with 681 additions and 655 deletions

View file

@ -89,10 +89,10 @@ fn process_files(files []string) ! {
fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref_ &pref.Preferences) &parser.Parser {
mut p := &parser.Parser{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}

View file

@ -87,10 +87,10 @@ fn process_files(files []string) ! {
fn new_parser(path string, comments_mode scanner.CommentsMode, table &ast.Table, pref_ &pref.Preferences) &parser.Parser {
mut p := &parser.Parser{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
scanner: scanner.new_scanner_file(path, comments_mode, pref_) or { panic(err) }
table: table
pref: pref_
scope: &ast.Scope{
start_pos: 0
parent: table.global_scope
}

View file

@ -22,8 +22,8 @@ struct BumpTestCase {
const test_cases = [
BumpTestCase{
file_name: 'v.mod'
contents: "Module {
file_name: 'v.mod'
contents: "Module {
name: 'Sample'
description: 'Sample project'
version: '1.2.6'
@ -38,8 +38,8 @@ const test_cases = [
expected_major: " version: '2.0.0'"
},
BumpTestCase{
file_name: 'random_versions.vv'
contents: "
file_name: 'random_versions.vv'
contents: "
1.1.2
1.2.5
3.21.73
@ -52,8 +52,8 @@ version = '1.5.1'
expected_major: "version = '2.0.0'"
},
BumpTestCase{
file_name: 'sample_tool.v'
contents: "// Module comment and copyright information
file_name: 'sample_tool.v'
contents: "// Module comment and copyright information
import os
import flag
@ -110,8 +110,8 @@ struct SkipTestCase {
const skip_test_cases = [
SkipTestCase{
file_name: 'CITATION.cff'
contents: 'abstract: A sample CLI tool made in V that prints geometric shapes to the screen.
file_name: 'CITATION.cff'
contents: 'abstract: A sample CLI tool made in V that prints geometric shapes to the screen.
authors:
- alias: hungrybluedev
family-names: Haldar

View file

@ -50,7 +50,7 @@ fn main() {
},
]
mut cmd := Command{
flags: [
flags: [
Flag{
flag: .bool
name: 'help'
@ -70,7 +70,7 @@ fn main() {
'The <project_name> argument can be omitted and entered in the prompts dialog.',
'If git is installed, `git init` will be performed during the setup.',
].join_lines()
parent: &Command{
parent: &Command{
name: 'v'
}
posix_mode: true
@ -87,7 +87,7 @@ fn main() {
'If no `.v` file exists, a project template is generated. If the current directory is not a',
'git project and git is installed, `git init` will be performed during the setup.',
].join_lines()
parent: &Command{
parent: &Command{
name: 'v'
}
posix_mode: true

View file

@ -10,7 +10,7 @@ mut:
// Default ignore patterns.
'': ['testdata', 'tests', '*_test.v']
}
paths map[string]bool
paths map[string]bool
}
fn get_modules(path string) []string {

View file

@ -155,7 +155,7 @@ fn (mut vd VDoc) create_search_results(mod string, dn doc.DocNode, out Output) {
dn_description := trim_doc_node_description(dn.name, comments)
vd.search_index << dn.name
vd.search_data << SearchResult{
prefix: if dn.parent_name != '' {
prefix: if dn.parent_name != '' {
'${dn.kind} (${dn.parent_name})'
} else {
'${dn.kind} '

View file

@ -299,7 +299,7 @@ fn (mut vd VDoc) generate_docs_from_file() {
println(markdown.to_plain(readme_contents))
} else if out.typ == .html && cfg.is_multi {
vd.docs << doc.Doc{
head: doc.DocNode{
head: doc.DocNode{
name: 'README'
comments: [comment]
}

View file

@ -87,7 +87,7 @@ fn new_repl(folder string) Repl {
vstartup_source := os.read_file(vstartup) or { '' }.trim_right('\n\r').split_into_lines()
os.mkdir_all(folder) or {}
return Repl{
readline: readline.Readline{
readline: readline.Readline{
skip_empty: true
}
folder: folder