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

Use setenv in vim to allow non alphanumeric vars #901

Merged
merged 1 commit into from Apr 14, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions internal/cmd/shell_vim.go
Expand Up @@ -33,16 +33,16 @@ func (sh vim) Dump(env Env) (out string) {
}

func (sh vim) export(key, value string) string {
return "let $" + sh.escapeKey(key) + " = " + sh.escapeValue(value) + "\n"
return "call setenv(" + sh.escapeKey(key) + "," + sh.escapeValue(value) + ")\n"
}

func (sh vim) unset(key string) string {
return "let $" + sh.escapeKey(key) + " = ''\n"
return "call setenv(" + sh.escapeKey(key) + ",v:null)\n"
}

// TODO: support keys with special chars or fail
func (sh vim) escapeKey(str string) string {
return str
return sh.escapeValue(str)
}

// TODO: Make sure this escaping is valid
Expand Down