Change:
Type: <bBug</b. After my PC hung and rebooted the VSCode suddenly starts output weird text in integrated terminal and beep each time when command is started/ended. The output looks like: I tried all suggested anwsers on SO, restarting VSCode after each attempt, but nothing worked: I tried to reinstall PowerShell 7 is . I tries to set it to I tried to install PowerShell extension and run both PowerShell: Disable ISE Mode (restore to defaults) and PowerShell: Enable ISE Mode When I run , none of that weird text appeared. I have nothing of those files: VS Code version: Code 1.70.3 (, 2022-08-31T08:03:55.990Z) OS version: WindowsNT x64 6.1.7601 Modes: <details<summarySystem Info</summary </details<details<summaryExtensions (37)</summaryExtensionVersion ------ rainbow-brackets0.0.6 better-comments3.0.2 numbered-bookmarks8.3.1 asciidoctor-vscode2.9.8 better-toml0.3.2 xml2.5.1 todo-tree0.0.215 reg1.1.0 rainbow-csv2.4.0 vscode-language-pack-ru1.70. python2022.14.0 vscode-pylance2022.9.10 jupyter2022.7. jupyter-keymap1.0.0 jupyter-renderers1.0.9 cpptools1.12.4 hexeditor1.9.8 autodocstring0.6.1 peggy-language2.3.0 java1.10.0 vscode-commons0.0.6 vscode-yaml1.10.1 rust0.7.8 scala0.5.6 crates0.5.10 pegjs-language1.0.4 vscode-fileutils3.5.0 code-spell-checker2.7.2 code-spell-checker-russian2.0.6 vscodeintellicode1.2.25 hg2.0.5 vscode-java-debug0.44.0 vscode-java-dependency0.21.0 vscode-java-pack0.25.1 vscode-java-test0.37.1 vscode-maven0.38.0 vscode-todo-highlight1.0.5 </details<details<summaryA/B Experiments</summary</details<!-- generated by issue reporter --
Thanks for creating this issue! It looks like you may be using an old version of VS Code, the latest stable release is 1.71.0. Please try upgrading to the latest version and checking whether this issue remains. Happy Coding!
I cannot install 1.71.0 because I'm on Windows 7 and support of Windows 7 was dropped in 1.71.0
setting to false should fix this for you
Thank you!!! That works!
Looks like this is Windows 7, so I don't think shell integration works using winpty. Reopening as we should disallow shell integration injection when conpty is not being used.
What is the best way to verify this?
This is probably best to do via an extra code review. If you have access to a Windows 7 machine, you can enable the shell integration setting, open pwsh and make sure the sequences don't show up.
But how to do that on Windows 7 considering that VSCode is no longer updated on Windows 7?
good point, Windows 8 or a old version of Windows 10 would also work. Any version before we support conpty (= build )
ممكن حل

Discussion:
*/ export function getShellIntegrationInjection( shellLaunchConfig: IShellLaunchConfig, <del> options: ITerminalProcessOptions['shellIntegration'], </del> <ins> options: Pick<ITerminalProcessOptions, 'shellIntegration' | 'windowsEnableConpty'>, </ins> env: ITerminalEnvironment | undefined, logService: ILogService, productService: IProductService

// - The global setting is disabled // - There is no executable (not sure what script to run) // - The terminal is used by a feature like tasks or debugging <del> if (!options.enabled || !shellLaunchConfig.executable || shellLaunchConfig.isFeatureTerminal || shellLaunchConfig.hideFromUser || shellLaunchConfig.ignoreShellIntegration) { </del> <ins> if (!options.shellIntegration.enabled || !shellLaunchConfig.executable || shellLaunchConfig.isFeatureTerminal || shellLaunchConfig.hideFromUser || shellLaunchConfig.ignoreShellIntegration || (isWindows && !options.windowsEnableConpty)) { </ins> return undefined; }

let injection: IShellIntegrationConfigInjection | undefined; if (this._options.shellIntegration.enabled) { <del> injection = getShellIntegrationInjection(this.shellLaunchConfig, this._options.shellIntegration, this._ptyOptions.env, this._logService, this._productService); </del> <ins> injection = getShellIntegrationInjection(this.shellLaunchConfig, { shellIntegration: this._options.shellIntegration, windowsEnableConpty: this._options.windowsEnableConpty }, this._ptyOptions.env, this._logService, this._productService); </ins> if (injection) { this._onDidChangeProperty.fire({ type: ProcessPropertyType.UsedShellIntegrationInjection, value: true }); if (injection.envMixin) {

import { deepStrictEqual, ok, strictEqual } from 'assert'; import { homedir, userInfo } from 'os'; <ins> import { isWindows } from 'vs/base/common/platform'; </ins> import { NullLogService } from 'vs/platform/log/common/log'; import { IProductService } from 'vs/platform/product/common/productService'; import { ITerminalProcessOptions } from 'vs/platform/terminal/common/terminal'; import { getShellIntegrationInjection, IShellIntegrationConfigInjection } from 'vs/platform/terminal/node/terminalEnvironment'; <del> const enabledProcessOptions: ITerminalProcessOptions['shellIntegration'] = { enabled: true }; const disabledProcessOptions: ITerminalProcessOptions['shellIntegration'] = { enabled: false }; </del> <ins> const enabledProcessOptions: Pick<ITerminalProcessOptions, 'shellIntegration' | 'windowsEnableConpty'> = { shellIntegration: { enabled: true }, windowsEnableConpty: true }; const disabledProcessOptions: Pick<ITerminalProcessOptions, 'shellIntegration' | 'windowsEnableConpty'> = { shellIntegration: { enabled: false }, windowsEnableConpty: true }; const winptyProcessOptions: Pick<ITerminalProcessOptions, 'shellIntegration' | 'windowsEnableConpty'> = { shellIntegration: { enabled: true }, windowsEnableConpty: false }; </ins> const pwshExe = process.platform === 'win32' ? 'pwsh.exe' : 'pwsh'; const repoRoot = process.platform === 'win32' ? process.cwd()[0].toLowerCase() + process.cwd().substring(1) : process.cwd(); const logService = new NullLogService();

ok(!getShellIntegrationInjection({ executable: pwshExe, args: ['-l', '-NoLogo'], isFeatureTerminal: true }, enabledProcessOptions, defaultEnvironment, logService, productService)); ok(getShellIntegrationInjection({ executable: pwshExe, args: ['-l', '-NoLogo'], isFeatureTerminal: false }, enabledProcessOptions, defaultEnvironment, logService, productService)); }); <ins> if (isWindows) { test('when on windows with conpty false', () => { ok(!getShellIntegrationInjection({ executable: pwshExe, args: ['-l'], isFeatureTerminal: false }, winptyProcessOptions, defaultEnvironment, logService, productService)); }); } </ins> }); suite('pwsh', () => {