Skip to content

Fixed several issues in the clink_vfox.lua script - #724

Merged
linghengqian merged 4 commits into
version-fox:mainfrom
jan-bar:clink_vfox
Oct 16, 2026
Merged

linghengqian merged 4 commits into
version-fox:mainfrom
jan-bar:clink_vfox

Conversation

@jan-bar

@jan-bar jan-bar commented Oct 15, 2026

Copy link
Copy Markdown
Contributor
  1. The output of the vfox available and vfox ls commands has changed; parsing scripts will need to be updated.
  2. Changed the regex matching in vfox_setenv to use the first = sign as the delimiter.
  3. Add parameter completion for unuse, exec, and x.
  4. Update the completions and flags for relevant parameters.

@codecov

codecov Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 34.99%. Comparing base (9aef814) to head (3ea54db).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #724   +/-   ##
=======================================
  Coverage   34.99%   34.99%           
=======================================
  Files          95       95           
  Lines        6704     6704           
=======================================
  Hits         2346     2346           
  Misses       4045     4045           
  Partials      313      313           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • It is not yet ready for merging. Although the CI tests have passed, the flags are correctly synchronized with the CLI, and the fix in vfox_setenv—which splits strings at the first = character—properly handles values ​​that contain = signs, there remain some functional issues within internal/shell/clink_vfox.lua.

  • Based on the logic in cmd/commands/unuse.go, the unuse command accepts only the raw SDK name (excluding the version number). Therefore, it should not reuse the autocompleter designed for the use and exec commands, which prompts for an sdk@version format. Furthermore, the matching patterns used by the available and ls commands—[%w%-] and ^%W*(%w.*)—are too restrictive; they fail to match names containing underscores or dots. A more robust approach would be to use (%S+) while properly handling any leading whitespace. Additionally, the method of matching [✓✗] by byte is fragile. The documentation also fails to mention the newly introduced __VFOX_SHELL variable or the "skip if unchanged" safeguard; given that internal/shell/clink.go already outputs __VFOX_SHELL, it is unclear whether this addition is intentional.

  • I recommend fixing the autocompleter for unuse, broadening the name-matching patterns, and documenting the design rationale behind __VFOX_SHELL. Since the current Windows CI tasks and Go tests do not cover this script, please ensure it is verified in a Windows/Clink environment before merging.

2. Update the autocompleter for `vfox unuse`
@jan-bar

jan-bar commented Oct 16, 2026

Copy link
Copy Markdown
Contributor Author

@linghengqian

  1. In version 0.9.2, I encountered an issue where the __VFOX_SHELL variable failed to be set correctly. While this may have been resolved in Set __VFOX_SHELL in all shell hooks to prevent spawning subprocess on global use #584 , an earlier change fix(vfox clink): clink coroutine execution failed #410 suggests that it is worth ensuring the necessary environment variables are set before running vfox activate clink, as this could help prevent unexpected problems.

  2. I recall that in earlier versions, no output was generated if the environment variables remained unchanged. However, in the current version specifically in the code block here:

vfox/cmd/commands/env.go

Lines 194 to 201 in 9aef814

if !changed {
cachedOutput := state.GetCachedOutput(shellName)
if cachedOutput != "" {
logger.Debugf("Using cached output")
fmt.Print(cachedOutput)
return nil
}
}

the program produces output every time a command is run, even when cached data is present. This causes the environment variables to be set repeatedly whenever the script is executed; consequently, I have implemented a check within my Lua script to ensure that environment variables are only updated when a change is actually detected.

  1. Modified unuse to utilize vfox_sdk_func for autocompletion.

  2. Based on the vfox available code below:

for _, item := range available {
isOfficial := strings.HasPrefix(item.Homepage, "https://github.com/version-fox/")
official := pterm.LightRed("✗")
if isOfficial {
official = pterm.LightGreen("✓")
}
nameCol := fmt.Sprintf("%-*s", nameWidth, item.Name)
pterm.Printf(" %s %s %s\n", pterm.FgCyan.Sprint(nameCol), official, pterm.FgLightWhite.Sprint(item.Homepage))
}

Need to extract only the data from lines that contain [✓✗], Therefore, the regular expression is changed to '^ (%S+)%s+[✓✗]'

  1. Based on the vfox ls code below:

root := putils.TreeFromLeveledList(tree)
root.Text = "All installed sdk versions"
// Render TreePrinter
_ = pterm.DefaultTree.WithRoot(root).Render()

https://github.com/pterm/pterm/blob/1800c6e07e7ea192b624a2066dec0a40c5bae340/tree_printer.go#L24-L34

https://github.com/pterm/pterm/blob/1800c6e07e7ea192b624a2066dec0a40c5bae340/tree_printer.go#L136-L160

Therefore, the regular expression is changed to '^[ ┬└│─├]*(%S.*)'

@linghengqian linghengqian left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve left a note regarding the unit tests at #728 , as they require refactoring. As for this PR, LGTM.

@linghengqian linghengqian added bug Something isn't working and removed need-more-info labels Oct 16, 2026
@linghengqian
linghengqian merged commit f05227a into version-fox:main Oct 16, 2026
6 checks passed
@jan-bar
jan-bar deleted the clink_vfox branch October 16, 2026 07:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants