budimanjojo / tmux.fish

Tmux plugin for fish shell
MIT License
63 stars 11 forks source link

fix: check `VSCODE_RESOLVING_ENVIRONMENT` env variable #3

Closed rriski closed 1 year ago

rriski commented 1 year ago

The January 2023 release of VSCode added a new VSCODE_RESOLVING_ENVIRONMENT variable (https://code.visualstudio.com/updates/v1_75#_new-vscoderesolvingenvironment-environment-variable) that is set to 1 when resolving user's shell environment.

Related to #1, this fixes the same issue for VSCode version >= 1.75.

budimanjojo commented 1 year ago

I believe test "$TERM_PROGRAM" != 'vscode' still work on VSCode version >= 1.75? There's no mention about they're deprecating $TERM_PROGRAM for $VSCODE_RESOLVING_ENVIRONMENT?

rriski commented 1 year ago

Unfortunately my tests suggest otherwise. Not sure why TERM_PROGRAM is not set anymore during initialization. To duplicate the issue and see what the ENV is during VSCode initialization do the following (this is on MacOS Ventura VSCode 1.75.0):

  1. Open Automator app, click Application
  2. Search "Run Shell Script"
  3. Set the script to open -a "Visual Studio Code.app" --args --crash-reporter-directory /Users/yourusername/vscode-dump/ --log trace
  4. Close VSCode
  5. Set set -U fish_tmux_autostart true && set -U fish_tmux_autostart_once true
  6. Go to /Users/yourusername/Library/Application Support/Code/logs, there should be multiple log folders named something like 20230208T114023. Remove them )
  7. Run the automator script, this opens vscode with trace logging enabled.
  8. Go to the latest log folder. Run cat main.log
  9. Look for a log line starting including getUnixShellEnvironment#env, this doesn't include TERM_PROGRAM anymore, only VSCODE_RESOLVING_ENVIRONMENT
❯ cat main.log | grep 'getUnixShellEnvironment#env'
2023-02-08 14:07:30.310 [trace] getUnixShellEnvironment#env {"PWD":"/Users/yourusername","MallocNanoZone":"0","USER":"yourusername","SECURITYSESSIONID":"186b4","COMMAND_MODE":"unix2003","__CFBundleIdentifier":"com.microsoft.VSCode","PATH":"/usr/bin:/bin:/usr/sbin:/sbin","LOGNAME":"yourusername","SSH_AUTH_SOCK":"/private/tmp/com.apple.launchd.MHgmPoHg3a/Listeners","SHLVL":"1","HOME":"/Users/yourusername","SHELL":"/opt/homebrew/bin/fish","_":"/usr/bin/open","TMPDIR":"/var/folders/yl/51y2f87n5jlfxmfffdt_c_080000gn/T/","LaunchInstanceID":"192329C3-C256-4F14-B27D-63319C8AE4C2","__CF_USER_TEXT_ENCODING":"0x1F5:0x0:0x0","XPC_SERVICE_NAME":"application.com.microsoft.VSCode.32703206.32703212","XPC_FLAGS":"0x0","ORIGINAL_XDG_CURRENT_DESKTOP":"undefined","VSCODE_CWD":"/","VSCODE_NLS_CONFIG":"{\"locale\":\"en-gb\",\"availableLanguages\":{},\"_languagePackSupport\":true}","VSCODE_CODE_CACHE_PATH":"/Users/yourusername/Library/Application Support/Code/CachedData/e2816fe719a4026ffa1ee0189dc89bdfdbafb164","VSCODE_IPC_HOOK":"/Users/yourusername/Library/Application Support/Code/1.75.0-main.sock","VSCODE_PID":"27380","ELECTRON_RUN_AS_NODE":"1","ELECTRON_NO_ATTACH_CONSOLE":"1","VSCODE_RESOLVING_ENVIRONMENT":"1"}

Code/logs/20230208T140730 on ☁️  (eu-west-1) 
❯ cat main.log | grep 'TERM_PROGRAM'

On earlier versions TERM_PROGRAM was set, on 1.75.0 it seems that it is not.

budimanjojo commented 1 year ago

Okay, thanks for the PR!