Repository navigation
Description
Type: Bug
So, I've been noticing this for a while now, but a lot of times (not every time) when I am using the terminal in VSCode and start typing, the initial first key press doesn't get recognized. I just thought it was a quirk and is easy enough to ignore...
BUT...
I have an extension I have authored that utilizes the terminal to execute commands. I have just noticed that (intermittently) when I call the sendText method, the first character of the string passed into that method also gets ignored.
Given the following code:
const terminal = vscode.window.createTerminal("MyTerminal");
terminal.sendText("cd ..");I would expect the command being sent to the terminal to be cd .., but in the terminal (and only sometimes) it attempts to execute d .. - which is obviously not what is expected.
Is there any way to mitigate this? Is this just a bug in the actual terminal?
VS Code version: Code 1.90.0 (89de5a8, 2024-06-04T19:33:54.889Z)
OS version: Windows_NT x64 10.0.22631
Modes:
System Info
| Item | Value |
|---|---|
| CPUs | 13th Gen Intel(R) Core(TM) i7-13620H (16 x 2918) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok skia_graphite: disabled_off video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 15.71GB (6.22GB free) |
| Process Argv | --crash-reporter-id 34d3cda8-5b84-4fa8-8387-6931ddf6106c |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368cf:30146710
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492:30256859
vscod805cf:30301675
binariesv615:30325510
vsaa593:30376534
py29gd2263:31024239
vscaat:30438848
c4g48928:30535728
azure-dev_surveyone:30548225
962ge761:30959799
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pythonmypyd1:30879173
h48ei257:31000450
pythontbext0:30879054
accentitlementst:30995554
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
cppperfnew:31000557
dsvsc020:30976470
pythonait:31006305
jchc7451:31067544
showvideot:31016892
chatpanelc:31048052
dsvsc021:30996838
jg8ic977:31013176
pythoncenvpt:31062603
a69g1124:31058053
dvdeprecation:31068756
pythonprt:31056678
dwnewjupyter:31046869
newcmakeconfigv2:31071590
26j00206:31048877
Activity
revrenlove commentedon Jun 13, 2024
Reddit Post
Stack Overflow Post
meganrogge commentedon Jun 13, 2024
what happens if you wait for this event and only then
sendText?vscode/src/vscode-dts/vscode.d.ts
Line 10448 in e5e6491
revrenlove commentedon Jun 13, 2024
The issue still (sometimes) happens when sending the command to an existing terminal.
revrenlove commentedon Jun 13, 2024
For context, this is the actual code. Basically, I check for a terminal named dotnet and use that if it already exists. The problem happens both on new terminal instances and existing ones.
Further, the commands may execute fine several times in a row on an existing terminal, and then randomly, it'll drop the first character on a
sendTextcall.Tyriar commentedon Jun 13, 2024
Can you show a screenshot of the issue and provide your settings.json? I have a suspicion I know what this is (emoji or other ambiguous special chars in the prompt).
revrenlove commentedon Jun 13, 2024
Note the error:
bash: d: command not found- it cut off the "c" character that should have been in there.settings.json:
{ "workbench.sideBar.location": "right", "workbench.colorCustomizations": { "[Blueberry Banana]": { "statusBar.debuggingBackground": "#b9355d" } }, "editor.codeActionsOnSave": { "source.fixAll": "explicit" }, "todo-tree.tree.showScanModeButton": false, "editor.suggestSelection": "first", "vsintellicode.modify.editor.suggestSelection": "automaticallyOverrodeDefaultValue", "editor.semanticHighlighting.enabled": true, "csharp.semanticHighlighting.enabled": true, "cSpell.userWords": [ "Activable", "Acxiom", "appsettings", "Architected", "ASMX", "classlib", "Cookeville", "dawg", "Deloitte", "displayport", "Dtos", "elrod", "enablement", "endregion", "Envitia's", "EODG", "esbuild", "fucky", "geolocation", "Grpc", "Healthtrust", "Jira", "Laughlin", "localdb", "Lucero", "microservice", "mocharc", "multitenant", "Murfreesboro", "nuget", "POCOs", "Readonly", "Referer", "repos", "Revren", "revrenlove", "RXNT", "Ryman", "Sencha", "SQLEXPRESS", "SSRS", "strang", "transpiled", "tsdoc", "Tweetinvi", "typeof", "Usings", "webapi", "Winform", "Xunit" ], "files.exclude": { "**/.vs": true, "**/node_modules": true, "**/bin": true, "**/obj": true }, "javascript.referencesCodeLens.enabled": true, "typescript.referencesCodeLens.enabled": true, "typescript.implementationsCodeLens.enabled": true, "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe", "glassit.alpha": 255, "workbench.iconTheme": "material-icon-theme", "omnisharp.enableRoslynAnalyzers": true, "[html]": { "editor.defaultFormatter": "vscode.html-language-features" }, "[typescript]": { "editor.defaultFormatter": "vscode.typescript-language-features" }, "[css]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "[yaml]": { "editor.insertSpaces": true, "editor.tabSize": 2, "editor.autoIndent": "advanced", "diffEditor.ignoreTrimWhitespace": false }, "typescript.updateImportsOnFileMove.enabled": "always", "git.autofetch": true, "debug.onTaskErrors": "debugAnyway", "[javascript]": { "editor.defaultFormatter": "esbenp.prettier-vscode" }, "mocha.coverage": { "enable": false }, "mocha.files.glob": "test/**/*.ts", "explorer.compactFolders": false, "python.languageServer": "Jedi", "csharpsortusings.sort.usings.splitGroups": false, "todo-tree.general.tags": [ "BUG", "HACK", "FIXME", "TODO", "XXX", "[ ]", "[x]" ], "todo-tree.regex.regex": "(//|#|<!--|;|/\\*|^|^\\s*(-|\\d+.))\\s*($TAGS)", "security.workspace.trust.untrustedFiles": "open", "[markdown]": { "editor.defaultFormatter": "DavidAnson.vscode-markdownlint" }, "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "javascript.referencesCodeLens.showOnAllFunctions": true, "typescript.referencesCodeLens.showOnAllFunctions": true, "bracket-pair-colorizer-2.depreciation-notice": false, "[csharp]": { "editor.defaultFormatter": "ms-dotnettools.csharp" }, "terminal.integrated.enableMultiLinePasteWarning": false, "git.confirmSync": false, "debug.javascript.unmapMissingSources": true, "typescript.tsserver.experimental.enableProjectDiagnostics": true, "todo-tree.highlights.customHighlight": { "BUG": { "icon": "bug" }, "HACK": { "icon": "tools" }, "FIXME": { "icon": "flame" }, "XXX": { "icon": "x" }, "[ ]": { "icon": "issue-draft" }, "[x]": { "icon": "issue-closed" } }, "terminal.integrated.defaultProfile.windows": "Git Bash", "git.enableSmartCommit": true, "[typescriptreact]": { "editor.tabSize": 4 }, "cSpell.ignorePaths": [ "package-lock.json", "node_modules", "vscode-extension", ".git/objects", ".vscode", ".vscode-insiders", "secrets.json" ], "prettier.tabWidth": 4, "c-sharp-utilities.jimTestConfigNext": 8673, "revUtil.Sandwich.IntToo": 97688, "cmake.configureOnOpen": true, "[aspnetcorerazor]": { "editor.defaultFormatter": "ms-dotnettools.csharp" }, "editor.minimap.enabled": false, "azureFunctions.showCoreToolsWarning": false, "c-sharp-utilities.usingStatementsToInclude": ["item 1", "item 2"], "c-sharp-utilities.newItemTemplate.namespacesToInclude": [ "System", "System.Text" ], "c-sharp-utilities.newItemTemplate.includeUsingStatements": true, "c-sharp-utilities.newItemTemplate.fileScopedNamespace": false, "githubIssues.queries": [ { "label": "My Issues", "query": "is:open assignee:${user} repo:${owner}/${repository}", "groupBy": ["milestone"] }, { "label": "Created Issues", "query": "author:${user} state:open repo:${owner}/${repository} sort:created-desc" }, { "label": "Recent Issues", "query": "state:open repo:${owner}/${repository} sort:updated-desc" } ], "c-sharp-utilities2.newItemTemplate.namespacesToInclude": [ "System", "System.Text", "Madness", "fssf", "sfsfn" ], "prettier.singleQuote": true }12 remaining items
adamerose commentedon Mar 11, 2025
This is a VERY annoying bug that happens on many different Windows machines for me for a long time now.
Git Bashas the default terminal, never withCommand PromptorPowerShellcreateTerminaland thensendText... I even made an extension to test it a bunch of times in a row but it never triggers it for meterminal.integrated.shellIntegration.enabledterminal.integrated.scrollbackterminal.integrated.enablePersistentSessionsterminal.integrated.commandsToSkipShellGit Bashprofile like"terminal.integrated.defaultProfile.windows": "Git Bash"or define my own custom profile with a path like this:quyenvsp commentedon Mar 11, 2025
Adam Rose (@adamerose) agree, it very annoying and not easy to reproduce. All I know is it happen from Jun 2, 2023 when Git for Windows v2.41.0.windows.1 released #187804 xtermjs/xterm.js#4600
Side question, do you use PowerToys or Windows Terminal (Preview)? I suspect this is coming from git bash rather than vscode
revrenlove commentedon Mar 11, 2025
I was looking for a source (couldn't find one), but at one point, I think I read that it has something to do with Windows's bash "emulator"... It's possible I'm talking out of my ass.
v2.😮 of C# Utilities Extension with functionality that doesn't need to worry about this coming soon.
adamerose commentedon Mar 11, 2025
I just spent an hour testing various Git Bash versions and it goes back much further than this. I reproduced the bug on every version I tried, which included
2.48.1,2.41,2.40,2.29,2.16and even2.7.4from 2016PowerToys the set of Windows utilities? I do use that, but not sure how it relates to Git Bash.
I thought the issue only happened when running Git Bash through the VS Code integrated terminal. I can confirm the bug happens in VS Code regardless of whether you install Git Bash with "Use MinTTY" or "Use Windows' default console window". This makes sense because the VSC integrated terminal is just using ConPTY with the Git Bash shell, it doesn't depend on what you pick as the Git Bash terminal.
I'll come back and update if I ever do run into it with the dedicated Git Bash terminal.
quyenvsp commentedon May 14, 2025
Adam Rose (@adamerose) these are new setting
terminal.integrated.windowsUseConptyDllcan you try?UncleGus commentedon May 21, 2025
I'm glad to find that it's not only affecting me. The number of times I have seen
$ it push --force bash: it: command not foundis too damn high.
quyenvsp commentedon May 29, 2025
After 2 weeks, I confirm
terminal.integrated.windowsUseConptyDllreally did something helpful. Before about 3 times / day, after that setting only about 2 times / 2 weeks. Less painful but still here!nycpivot commentedon Jul 30, 2025
I'm getting sick of this too. FIX IT.
revrenlove commentedon Jul 30, 2025
Tyriar commentedon Jul 31, 2025
FYI the original report is different to the conpty problem which is tracked in #243584
terminal.integrated.windowsUseConptyDllwas true for a while in insiders but was switched back to false because of some outstanding problems which the first input getting missed after reloading the window being one of the bigger ones. Setting that to false should fix that problem specifically if you has it explicitly set (since false is the default).quyenlv-unicloud commentedon Aug 8, 2025
from May 29
terminal.integrated.windowsUseConptyDll: truework fine for me on Git bash for Windows with Zsh + Pure theme. Only about 3 times / 2 months.But now when upgrade latest version 1.102.3 it happen again too many times again per day, really hope we will found stable version of conpty soon.
Tyriar commentedon Oct 15, 2025
/duplicate #243584