wez / wezterm

A GPU-accelerated cross-platform terminal emulator and multiplexer written by @wez and implemented in Rust
https://wezfurlong.org/wezterm/
Other
17.28k stars 781 forks source link

SetUserVar value max chars on 58 chars #3688

Closed dantesg closed 1 year ago

dantesg commented 1 year ago

What Operating System(s) are you seeing this problem on?

Windows

Which Wayland compositor or X11 Window manager(s) are you using?

No response

WezTerm version

wezterm 20230408-112425-69ae8472

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

When I run the following command to set the user var I get only partial string on wezterm.on('user-var-changed'

printf "\033]1337;SetUserVar=%s=%s\007" workspace $(echo -n "name=resolveentrymoduleswebpackplugin_S cwd=D:\GitHub\resolve-entry-modules-webpack-plugin" | base64)

expected: logging ←[0m > lua: var workspace name=resolveentrymoduleswebpackplugin_S cwd=D:\GitHub\resolve-entry-modules-webpack-plugin

actual: logging ←[0m > lua: var workspace name=resolveentrymoduleswebpackplugin_S cwd=D:\GitHub\res

Is that by design or I'm missing a limitation?

To Reproduce

run:

printf "\033]1337;SetUserVar=%s=%s\007" workspace $(echo -n "name=resolveentrymoduleswebpackplugin_S cwd=D:\GitHub\resolve-entry-modules-webpack-plugin" | base64)

watch log:

wezterm.on('user-var-changed', function(window, pane, name, value)
  value = value:gsub("\r\n", "")
  wezterm.log_info('var', name, value)
end)

Configuration

noconfig

Expected Behavior

It should be able to accept a larger amount of characters when setting user var

Logs

No response

Anything else?

No response

wez commented 1 year ago

You need to quote your \ characters, because \r in particular is meaningful to the shell:

$ echo -n "name=resolveentrymoduleswebpackplugin_S cwd=D:\GitHub\resolve-entry-modules-webpack-plugin" | base64
bmFtZT1yZXNvbHZlZW50cnltb2R1bGVzd2VicGFja3BsdWdpbl9TIGN3ZD1EOlxHaXRIdWINZXNv
bHZlLWVudHJ5LW1vZHVsZXMtd2VicGFjay1wbHVnaW4=

Which leads to this; if you intentionally de-fang the OSC sequence so that you can see the output:

$ printf "_033_1337;SetUserVar=%s=%s" workspace $(echo -n "name=resolveentrymoduleswebpackplugin_S cwd=D:\GitHub\resolve-entry-modules-webpack-plugin" | base64)
_033_1337;SetUserVar=workspace=bmFtZT1yZXNvbHZlZW50cnltb2R1bGVzd2VicGFja3BsdWdpbl9TIGN3ZD1EOlxHaXRIdWINZXNv_033_1337;SetUserVar=bHZlLWVudHJ5LW1vZHVsZXMtd2VicGFjay1wbHVnaW4==
dantesg commented 1 year ago

perfect! thanks for your help, I understand the problem now. I'll leave the approach I've taken here just in case someone else needs it. Tested on pwsh 7

$OPEN_S = "resolveentrymoduleswebpackplugin"
$OPEN_CWD = "D:\GitHub\resolve-entry-modules-webpack-plugin"
$MYTEXT = "name=$OPEN_S cwd=$OPEN_CWD"
$ENCODED = [System.Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes($MYTEXT))
printf "\033]1337;SetUserVar=%s=%s\007" workspace $(echo -n "$ENCODED")
github-actions[bot] commented 1 year ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.