Skip to content

Commit b18d8aa

Browse files
authored
Fix config command when using vscode (#926)
1 parent 49b6b9c commit b18d8aa

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/main/bash/sdkman-config.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
#
1818

1919
function __sdk_config() {
20-
local -r editor=${EDITOR:=vi}
20+
local -r editor=(${EDITOR:=vi})
2121

22-
if ! command -v "$editor" > /dev/null; then
22+
if ! command -v "${editor[@]}" > /dev/null; then
2323
__sdkman_echo_red "No default editor configured."
2424
__sdkman_echo_yellow "Please set the default editor with the EDITOR environment variable."
2525

2626
return 1
2727
fi
2828

29-
"$editor" "${SDKMAN_DIR}/etc/config"
29+
"${editor[@]}" "${SDKMAN_DIR}/etc/config"
3030
}

src/test/groovy/sdkman/specs/ConfigCommandSpec.groovy

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ class ConfigCommandSpec extends SdkmanEnvSpecification {
2323
where:
2424
setupEnv << [
2525
{
26-
it.execute('nano() { echo "nano was called with $1"; }')
26+
it.execute('nano() { echo "nano was called with $*"; }')
2727
it.execute("EDITOR=nano")
2828
},
2929
{
30-
it.execute('vi() { echo "vi was called with $1"; }')
30+
it.execute('code() { echo "code was called with $*"; }')
31+
it.execute("EDITOR='code --wait'")
32+
},
33+
{
34+
it.execute('vi() { echo "vi was called with $*"; }')
3135
it.execute("unset EDITOR")
3236
},
3337
{
@@ -36,6 +40,7 @@ class ConfigCommandSpec extends SdkmanEnvSpecification {
3640
]
3741
verifyOutput << [
3842
{ output, baseDirectory -> output.contains("nano was called with ${baseDirectory}/.sdkman/etc/config") },
43+
{ output, baseDirectory -> output.contains("code was called with --wait ${baseDirectory}/.sdkman/etc/config") },
3944
{ output, baseDirectory -> output.contains("vi was called with ${baseDirectory}/.sdkman/etc/config") },
4045
{ output, _ -> output.contains("No default editor configured.") }
4146
]

0 commit comments

Comments
 (0)