We could make session watcher script initialization more robust with the following applied:
init.R detects if environment variable TERM_PROGRAM=vscode. Only in VSCode it is effective.
~/.Rprofile only sources init.R when ~/.vscode-R/init.R exists. Disabling r.sessionWatcher removes ~/.vscode-R/init.R so that user does not have to comment out or remove the source() line manually.
The only drawback of detecting TERM_PROGRAM=vscode is that if R is started in a pre-existing environment inside a terminal multiplexer (e.g. tmux and screen) whose server program is not started inside VSCode terminal, it won't get a TERM_PROGRAM=vscode environment variable. But user could always set this environment variable to force it.
This is related to #190, #195, randy3k/radian#139. When user tries to disable session watcher by setting "r.sessionWatcher": false but leaves source(...) line in ~/.Rprofile or any other startup script, the use of all R sessions will be broken.
We could make session watcher script initialization more robust with the following applied:
init.Rdetects if environment variableTERM_PROGRAM=vscode. Only in VSCode it is effective.~/.Rprofileonly sourcesinit.Rwhen~/.vscode-R/init.Rexists. Disablingr.sessionWatcherremoves~/.vscode-R/init.Rso that user does not have to comment out or remove thesource()line manually.The only drawback of detecting
TERM_PROGRAM=vscodeis that if R is started in a pre-existing environment inside a terminal multiplexer (e.g.tmuxandscreen) whose server program is not started inside VSCode terminal, it won't get aTERM_PROGRAM=vscodeenvironment variable. But user could always set this environment variable to force it.This is related to #190, #195, randy3k/radian#139. When user tries to disable session watcher by setting
"r.sessionWatcher": falsebut leavessource(...)line in~/.Rprofileor any other startup script, the use of all R sessions will be broken.