mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
all: simplify return if ...
constructs to make more code compatible with -autofree
This commit is contained in:
@ -49,7 +49,7 @@ const (
|
||||
// Snooped from cmd/v/v.v, vlib/v/pref/pref.v
|
||||
const (
|
||||
auto_complete_commands = [
|
||||
/* simple_cmd */
|
||||
// simple_cmd
|
||||
'fmt',
|
||||
'up',
|
||||
'vet',
|
||||
@ -69,7 +69,7 @@ const (
|
||||
'setup-freetype',
|
||||
'doc',
|
||||
'doctor',
|
||||
/* commands */
|
||||
// commands
|
||||
'help',
|
||||
'new',
|
||||
'init',
|
||||
@ -219,7 +219,8 @@ fn auto_complete(args []string) {
|
||||
shell := sub_args[1]
|
||||
mut setup := ''
|
||||
match shell {
|
||||
'bash' { setup = '
|
||||
'bash' {
|
||||
setup = '
|
||||
_v_completions() {
|
||||
local src
|
||||
local limit
|
||||
@ -233,15 +234,19 @@ _v_completions() {
|
||||
}
|
||||
|
||||
complete -o nospace -F _v_completions v
|
||||
' }
|
||||
'fish' { setup = '
|
||||
'
|
||||
}
|
||||
'fish' {
|
||||
setup = '
|
||||
function __v_completions
|
||||
# Send all words up to the one before the cursor
|
||||
$vexe complete fish (commandline -cop)
|
||||
end
|
||||
complete -f -c v -a "(__v_completions)"
|
||||
' }
|
||||
'zsh' { setup = '
|
||||
'
|
||||
}
|
||||
'zsh' {
|
||||
setup = '
|
||||
#compdef v
|
||||
_v() {
|
||||
local src
|
||||
@ -253,15 +258,18 @@ _v() {
|
||||
fi
|
||||
}
|
||||
compdef _v v
|
||||
' }
|
||||
'powershell' { setup = '
|
||||
'
|
||||
}
|
||||
'powershell' {
|
||||
setup = '
|
||||
Register-ArgumentCompleter -Native -CommandName v -ScriptBlock {
|
||||
param(\$commandName, \$wordToComplete, \$cursorPosition)
|
||||
$vexe complete powershell "\$wordToComplete" | ForEach-Object {
|
||||
[System.Management.Automation.CompletionResult]::new(\$_, \$_, \'ParameterValue\', \$_)
|
||||
}
|
||||
}
|
||||
' }
|
||||
'
|
||||
}
|
||||
else {}
|
||||
}
|
||||
println(setup)
|
||||
@ -307,11 +315,10 @@ Register-ArgumentCompleter -Native -CommandName v -ScriptBlock {
|
||||
// append_separator_if_dir is a utility function.that returns the input `path` appended an
|
||||
// OS dependant path separator if the `path` is a directory.
|
||||
fn append_separator_if_dir(path string) string {
|
||||
return if os.is_dir(path) && !path.ends_with(os.path_separator) {
|
||||
path + os.path_separator
|
||||
} else {
|
||||
path
|
||||
if os.is_dir(path) && !path.ends_with(os.path_separator) {
|
||||
return path + os.path_separator
|
||||
}
|
||||
return path
|
||||
}
|
||||
|
||||
// auto_complete_request retuns a list of completions resolved from a full argument list.
|
||||
|
@ -356,7 +356,10 @@ fn html_highlight(code string, tb &table.Table) string {
|
||||
} else {
|
||||
tok.lit
|
||||
}
|
||||
return if typ in [.unone, .name] { lit } else { '<span class="token $typ">$lit</span>' }
|
||||
if typ in [.unone, .name] {
|
||||
return lit
|
||||
}
|
||||
return '<span class="token $typ">$lit</span>'
|
||||
}
|
||||
mut s := scanner.new_scanner(code, .parse_comments, &pref.Preferences{})
|
||||
mut tok := s.scan()
|
||||
|
Reference in New Issue
Block a user