Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions .github/workflows/v_apps_and_modules_compile_ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -157,18 +157,18 @@ jobs:
echo "Build v-analyzer release"
v build.vsh release

- name: Format vlang/v-analyzer
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: |
cd /tmp/v-analyzer
set +e
v fmt -c .
exit_code=$?
if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
# Don't fail if there are only internal errors (exit code 5).
v fmt -diff .
exit 1
fi
# - name: Format vlang/v-analyzer
# if: ${{ !cancelled() && steps.build.outcome == 'success' }}
# run: |
# cd /tmp/v-analyzer
# set +e
# v fmt -c .
# exit_code=$?
# if [[ $exit_code -ne 0 && $exit_code -ne 5 ]]; then
# # Don't fail if there are only internal errors (exit code 5).
# v fmt -diff .
# exit 1
# fi

- name: Build vlang/go2v
if: ${{ !cancelled() && steps.build.outcome == 'success' && matrix.os != 'macos-14' }}
Expand Down
8 changes: 4 additions & 4 deletions cmd/tools/measure/fmt_speed.v
Original file line number Diff line number Diff line change
Expand Up @@ -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{
spytheman marked this conversation as resolved.
Show resolved Hide resolved
start_pos: 0
parent: table.global_scope
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/tools/measure/parser_speed.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/modules/testing/common.v
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ pub mut:
vargs string
fail_fast bool
benchmark benchmark.Benchmark
rm_binaries bool = true
build_tools bool // builds only executables in cmd/tools; used by `v build-tools'
rm_binaries bool = true
build_tools bool // builds only executables in cmd/tools; used by `v build-tools'
spytheman marked this conversation as resolved.
Show resolved Hide resolved
silent_mode bool
show_stats bool
show_asserts bool
Expand All @@ -92,7 +92,7 @@ pub mut:
nmessage_idx int // currently printed message index
failed_cmds shared []string
reporter Reporter = Reporter(NormalReporter{})
hash string // used as part of the name of the temporary directory created for tests, to ease cleanup
hash string // used as part of the name of the temporary directory created for tests, to ease cleanup

exec_mode ActionMode = .compile // .compile_and_run only for `v test`
}
Expand Down
16 changes: 8 additions & 8 deletions cmd/tools/vbump_test.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ struct BumpTestCase {

const test_cases = [
BumpTestCase{
file_name: 'v.mod'
contents: "Module {
file_name: 'v.mod'
contents: "Module {
spytheman marked this conversation as resolved.
Show resolved Hide resolved
name: 'Sample'
description: 'Sample project'
version: '1.2.6'
Expand All @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/vcreate/vcreate.v
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ fn main() {
},
]
mut cmd := Command{
flags: [
flags: [
Flag{
flag: .bool
name: 'help'
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/files.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vdoc/html.v
Original file line number Diff line number Diff line change
Expand Up @@ -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} '
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/vdoc/main.v
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ const allowed_formats = ['md', 'markdown', 'json', 'text', 'ansi', 'html', 'htm'

struct Config {
mut:
pub_only bool = true
pub_only bool = true
show_loc bool // for plaintext
is_color bool
is_multi bool
is_vlib bool
is_verbose bool
include_readme bool
include_examples bool = true
include_examples bool = true
include_comments bool // for plaintext
inline_assets bool
theme_dir string = default_theme
theme_dir string = default_theme
no_timestamp bool
output_path string
output_type OutputType = .unset
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/vdoc/vdoc.v
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ mut:
search_data []SearchResult
search_module_index []string // search results are split into a module part and the rest
search_module_data []SearchModuleResult
example_failures int // how many times an example failed to compile or run with non 0 exit code; when positive, finish with exit code 1
example_oks int // how many ok examples were found when `-run-examples` was passed, that compiled and finished with 0 exit code.
example_failures int // how many times an example failed to compile or run with non 0 exit code; when positive, finish with exit code 1
example_oks int // how many ok examples were found when `-run-examples` was passed, that compiled and finished with 0 exit code.
}

//
Expand Down Expand Up @@ -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]
}
Expand Down
10 changes: 5 additions & 5 deletions cmd/tools/vrepeat.v
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,19 @@ mut:
warmup int
show_help bool
show_output bool
use_newline bool // use \n instead of \r, so the last line is not overwritten
use_newline bool // use \n instead of \r, so the last line is not overwritten
fail_on_regress_percent int
fail_on_maxtime int // in ms
fail_on_maxtime int // in ms
verbose bool
commands []string
results []CmdResult
cmd_template string // {T} will be substituted with the current command
cmd_params map[string][]string
cline string // a terminal clearing line
cgoback string
nmins int // number of minimums to discard
nmaxs int // number of maximums to discard
ignore_failed bool // ignore commands that exit with != 0 exit code
nmins int // number of minimums to discard
nmaxs int // number of maximums to discard
ignore_failed bool // ignore commands that exit with != 0 exit code
}

fn new_aints(ovals []i64, extreme_mins int, extreme_maxs int) Aints {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vrepl.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cmd/tools/vtest-all.v
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ mut:
ends_with string = ends_with_nothing
contains string = contains_nothing
output string
before_cb FnCheck = unsafe { nil }
after_cb FnCheck = unsafe { nil }
before_cb FnCheck = unsafe { nil }
after_cb FnCheck = unsafe { nil }
}

fn get_all_commands() []Command {
Expand Down
10 changes: 5 additions & 5 deletions cmd/tools/vtest-parser.v
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ mut:
is_help bool
is_worker bool
is_verbose bool
is_silent bool // do not print any status/progress during processing, just failures.
is_linear bool // print linear progress log, without trying to do term cursor up + \r msg. Easier to use in a CI job
show_src bool // show the partial source, that cause the parser to panic/fault, when it happens.
is_silent bool // do not print any status/progress during processing, just failures.
is_linear bool // print linear progress log, without trying to do term cursor up + \r msg. Easier to use in a CI job
show_src bool // show the partial source, that cause the parser to panic/fault, when it happens.
timeout_ms int
myself string // path to this executable, so the supervisor can launch worker processes
all_paths []string // all files given to the supervisor process
Expand All @@ -34,8 +34,8 @@ mut:
// parser context in the worker processes:
table ast.Table
pref &pref.Preferences = unsafe { nil }
period_ms int // print periodic progress
stop_print bool // stop printing the periodic progress
period_ms int // print periodic progress
stop_print bool // stop printing the periodic progress
}

fn main() {
Expand Down
2 changes: 1 addition & 1 deletion cmd/tools/vvet/errors.v
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub mut:
kind ErrorKind @[required]
pub:
// General message
message string @[required]
message string @[required]
details string // Details about how to resolve or fix the situation
file_path string // file where the error have origin
pos token.Pos // position in the file
Expand Down
6 changes: 3 additions & 3 deletions cmd/tools/vwatch.v
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ enum RerunCommand {

struct Context {
mut:
pid int // the pid of the current process; useful while debugging manager/worker interactions
is_worker bool // true in the workers, false in the manager process
check_period_ms int = scan_period_ms
pid int // the pid of the current process; useful while debugging manager/worker interactions
is_worker bool // true in the workers, false in the manager process
check_period_ms int = scan_period_ms
vexe string
affected_paths []string
vfiles []VFileStat
Expand Down
16 changes: 8 additions & 8 deletions examples/2048/2048.v
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ mut:
gg &gg.Context = unsafe { nil }
touch TouchInfo
ui Ui
theme &Theme = themes[0]
theme &Theme = themes[0]
theme_idx int
board Board
undo []Undo
atickers [4][4]int
state GameState = .play
tile_format TileFormat = .normal
state GameState = .play
tile_format TileFormat = .normal
moves int

is_ai_mode bool
ai_fpm u64 = 8
ai_fpm u64 = 8
}

struct Ui {
Expand Down Expand Up @@ -827,7 +827,7 @@ fn on_event(e &gg.Event, mut app App) {
if e.num_touches > 0 {
t := e.touches[0]
app.touch.start = Touch{
pos: Pos{
pos: Pos{
x: int(t.pos_x / app.ui.dpi_scale)
y: int(t.pos_y / app.ui.dpi_scale)
}
Expand All @@ -839,7 +839,7 @@ fn on_event(e &gg.Event, mut app App) {
if e.num_touches > 0 {
t := e.touches[0]
app.touch.end = Touch{
pos: Pos{
pos: Pos{
x: int(t.pos_x / app.ui.dpi_scale)
y: int(t.pos_y / app.ui.dpi_scale)
}
Expand All @@ -850,7 +850,7 @@ fn on_event(e &gg.Event, mut app App) {
}
.mouse_down {
app.touch.start = Touch{
pos: Pos{
pos: Pos{
x: int(e.mouse_x / app.ui.dpi_scale)
y: int(e.mouse_y / app.ui.dpi_scale)
}
Expand All @@ -859,7 +859,7 @@ fn on_event(e &gg.Event, mut app App) {
}
.mouse_up {
app.touch.end = Touch{
pos: Pos{
pos: Pos{
x: int(e.mouse_x / app.ui.dpi_scale)
y: int(e.mouse_y / app.ui.dpi_scale)
}
Expand Down
8 changes: 4 additions & 4 deletions examples/clock/clock.v
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ const second_hand_color = gx.red
struct App {
minutes_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
tp + 1 * th, center - tw, tp + 1 * th]
hours_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 2 * th,
center - tw, tp + 2 * th]
hours3_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw, tp + 3 * th,
center - tw, tp + 3 * th]
hours_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
tp + 2 * th, center - tw, tp + 2 * th]
hours3_tic []f32 = [f32(center - tw), tp, center + tw, tp, center + tw, tp, center + tw,
tp + 3 * th, center - tw, tp + 3 * th]

hour_hand []f32 = [f32(329), 161, 350, 140, 371, 161, 371, 413, 329, 413]
minute_hand []f32 = [f32(334.25), 40.25, 350, 24.5, 365.75, 40.25, 365.75, 427, 334.25, 427]
Expand Down
2 changes: 1 addition & 1 deletion examples/database/orm.v
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ struct User {
}

struct Parent {
id int @[primary; sql: serial]
id int @[primary; sql: serial]
name string
children []Child @[fkey: 'parent_id']
}
Expand Down
2 changes: 1 addition & 1 deletion examples/fireworks/modules/objects/rocket.v
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub fn new_rocket() Rocket {
pos: Vector{
x: rand.f32_in_range(50, get_params().width - 50) or { 50 }
}
vel: Vector{
vel: Vector{
x: rand.f32_in_range(-1.5, 1.5) or { -1.5 }
y: rand.f32_in_range(5, 7) or { 5 }
}
Expand Down
Loading
Loading