mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: remove trailing space in comments (#9620)
This commit is contained in:
parent
6d77c8821b
commit
1d5ed89138
@ -29,7 +29,7 @@ fn C.GC_REALLOC(ptr voidptr, n size_t) voidptr
|
||||
fn C.GC_FREE(ptr voidptr)
|
||||
|
||||
// explicitely perform garbage collection now! Garbage collections
|
||||
// are done automatically when needed, so this function is hardly needed
|
||||
// are done automatically when needed, so this function is hardly needed
|
||||
fn C.GC_gcollect()
|
||||
|
||||
// functions to temporarily suspend/resume garbage collection
|
||||
|
@ -31,7 +31,7 @@ pub fn sym(handle voidptr, symbol string) voidptr {
|
||||
}
|
||||
|
||||
// dlerror provides a text error diagnostic message for functions in `dl`
|
||||
// it returns a human-readable string, describing the most recent error
|
||||
// it returns a human-readable string, describing the most recent error
|
||||
// that occurred from a call to one of the `dl` functions, since the last
|
||||
// call to dlerror()
|
||||
pub fn dlerror() string {
|
||||
|
@ -28,7 +28,7 @@ pub fn sym(handle voidptr, symbol string) voidptr {
|
||||
}
|
||||
|
||||
// dlerror provides a text error diagnostic message for functions in `dl`
|
||||
// it returns a human-readable string, describing the most recent error
|
||||
// it returns a human-readable string, describing the most recent error
|
||||
// that occurred from a call to one of the `dl` functions, since the last
|
||||
// call to dlerror()
|
||||
pub fn dlerror() string {
|
||||
|
@ -11,7 +11,7 @@ const (
|
||||
fn testsuite_begin() ? {
|
||||
os.rm(test_os_process) or {}
|
||||
if os.getenv('WINE_TEST_OS_PROCESS_EXE') != '' {
|
||||
// Make it easier to run the test under wine emulation, by just
|
||||
// Make it easier to run the test under wine emulation, by just
|
||||
// prebuilding the executable with:
|
||||
// v -os windows -o x.exe cmd/tools/test_os_process.v
|
||||
// WINE_TEST_OS_PROCESS_EXE=x.exe ./v -os windows vlib/os/process_test.v
|
||||
|
@ -44,7 +44,7 @@ pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
|
||||
}
|
||||
} else if !node.text.contains('\n') {
|
||||
is_separate_line := !options.inline || node.text.starts_with('\x01')
|
||||
mut s := node.text.trim_left('\x01')
|
||||
mut s := node.text.trim_left('\x01').trim_right(' ')
|
||||
mut out_s := '//'
|
||||
if s != '' {
|
||||
if is_char_alphanumeric(s[0]) {
|
||||
@ -67,7 +67,7 @@ pub fn (mut f Fmt) comment(node ast.Comment, options CommentsOptions) {
|
||||
f.writeln('')
|
||||
}
|
||||
for line in lines {
|
||||
f.writeln(line)
|
||||
f.writeln(line.trim_right(' '))
|
||||
f.empty_line = false
|
||||
}
|
||||
if end_break {
|
||||
|
10
vlib/v/fmt/tests/trailing_space_expected.vv
Normal file
10
vlib/v/fmt/tests/trailing_space_expected.vv
Normal file
@ -0,0 +1,10 @@
|
||||
// NB: The input file has and *should* have trailing spaces.
|
||||
// When making changes, please ensure these spaces are not removed.
|
||||
|
||||
fn comments_with_trailing_space() {
|
||||
// two spaces on the right
|
||||
/*
|
||||
spaces after here
|
||||
and everywhere :)
|
||||
*/
|
||||
}
|
10
vlib/v/fmt/tests/trailing_space_input.vv
Normal file
10
vlib/v/fmt/tests/trailing_space_input.vv
Normal file
@ -0,0 +1,10 @@
|
||||
// NB: The input file has and *should* have trailing spaces.
|
||||
// When making changes, please ensure these spaces are not removed.
|
||||
|
||||
fn comments_with_trailing_space() {
|
||||
// two spaces on the right
|
||||
/*
|
||||
spaces after here
|
||||
and everywhere :)
|
||||
*/
|
||||
}
|
@ -61,15 +61,15 @@ pub fn (mut p Preferences) fill_with_defaults() {
|
||||
// locate resources relative to it. That enables running examples like
|
||||
// this:
|
||||
// `./v run examples/flappylearning/`
|
||||
// instead of:
|
||||
// instead of:
|
||||
// `./v -o examples/flappylearning/flappylearning run examples/flappylearning/`
|
||||
// This topic comes up periodically from time to time on Discord, and
|
||||
// many CI breakages already happened, when someone decides to make V
|
||||
// behave in this aspect similarly to the dumb behaviour of other
|
||||
// compilers.
|
||||
//
|
||||
// If you do decide to break it, please *at the very least*, test it
|
||||
// extensively, and make a PR about it, instead of commiting directly
|
||||
// If you do decide to break it, please *at the very least*, test it
|
||||
// extensively, and make a PR about it, instead of commiting directly
|
||||
// and breaking the CI, VC, and users doing `v up`.
|
||||
if rpath == '$p.vroot/cmd/v' && os.is_dir('vlib/compiler') {
|
||||
// Building V? Use v2, since we can't overwrite a running
|
||||
|
@ -24,7 +24,7 @@ fn test_inline_asm() {
|
||||
mov f, d
|
||||
add f, e
|
||||
add f, 5
|
||||
; +r (f) // output
|
||||
; +r (f) // output
|
||||
; r (d)
|
||||
r (e) // input
|
||||
}
|
||||
@ -45,7 +45,7 @@ fn test_inline_asm() {
|
||||
|
||||
mut j := 0
|
||||
// do 5*3
|
||||
// adding three, five times
|
||||
// adding three, five times
|
||||
asm amd64 {
|
||||
mov rcx, 5 // loop 5 times
|
||||
loop_start:
|
||||
|
@ -25,7 +25,7 @@ fn test_inline_asm() {
|
||||
mov f, d
|
||||
add f, e
|
||||
add f, 5
|
||||
; +r (f) // output
|
||||
; +r (f) // output
|
||||
; r (d)
|
||||
r (e) // input
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ fn sine(note &Note, time f32, amp f32) f32 {
|
||||
pub fn new_context(cfg Config) fn (&Note, f32, f32) f32 {
|
||||
// Note, that here `sine` and `sawtooth`,
|
||||
// are different functions, but they do have
|
||||
// a compatible signature, so `next_fn` can
|
||||
// a compatible signature, so `next_fn` can
|
||||
// become either one of them:
|
||||
next_fn := match cfg.wave_kind {
|
||||
.sine { sine }
|
||||
|
@ -10,7 +10,7 @@ fn (mut p Player) set_name(name string) &Player {
|
||||
return p // because of automatic (de)reference of return values
|
||||
}
|
||||
|
||||
// NB: `p` is declared as a `mut` parameter,
|
||||
// NB: `p` is declared as a `mut` parameter,
|
||||
// which now only affects its mutability.
|
||||
fn (mut p Player) set_position(x int, y int) &Player {
|
||||
p.x = x
|
||||
|
@ -6,7 +6,7 @@ fn test_mod1_can_still_be_found_through_parent_project_vmod() {
|
||||
|
||||
/*
|
||||
NB: this main program is under bin/ , but it still
|
||||
can find mod1, because the parent project has v.mod,
|
||||
can find mod1, because the parent project has v.mod,
|
||||
so v module lookup for this program will find mod1 through
|
||||
relation to the parent v.mod file
|
||||
*/
|
||||
|
@ -7,8 +7,8 @@ println('This script is located inside: ' + resource_abs_path(''))
|
||||
println('The result of calling m.f is: ' + m.f().str())
|
||||
|
||||
/*
|
||||
NB: this main program v script is under bin/ ,
|
||||
but it *still* can find mod1, because the parent project has v.mod,
|
||||
so v module lookup for this bin/main.vsh file will find mod1 through
|
||||
NB: this main program v script is under bin/ ,
|
||||
but it *still* can find mod1, because the parent project has v.mod,
|
||||
so v module lookup for this bin/main.vsh file will find mod1 through
|
||||
relation to the parent ../v.mod file
|
||||
*/
|
||||
|
@ -2,7 +2,7 @@ module submodule
|
||||
|
||||
/*
|
||||
This submodule just imports its sibling submodules.
|
||||
Note that they are NOT under 'submodule' itself,
|
||||
Note that they are NOT under 'submodule' itself,
|
||||
but are in its parent mod1 , and mod1 has a 'v.mod' file.
|
||||
*/
|
||||
import v.tests.project_with_modules_having_submodules.mod1.mod11
|
||||
|
@ -572,7 +572,7 @@ fn handle(e Expr) string {
|
||||
|
||||
// Binary Search Tree test by @SleepyRoy
|
||||
// TODO: make Node.value generic once it's robust enough
|
||||
// TODO: `return match` instead of returns everywhere inside match
|
||||
// TODO: `return match` instead of returns everywhere inside match
|
||||
|
||||
struct Empty {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user