Open revrenlove opened 3 months ago
what happens if you wait for this event and only then sendText
?
The issue still (sometimes) happens when sending the command to an existing terminal.
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 sendText
call.
import * as vscode from 'vscode';
import { DotnetCommand } from '../models/dotnetCommand';
const terminalName = 'dotnet';
function executeCommand(directoryPath: string, dotnetCommand: DotnetCommand, ...commandArgs: string[]) {
const terminal = ensureTerminal(directoryPath);
let command = `dotnet ${dotnetCommand}`;
if (commandArgs && commandArgs.length > 0) {
command += ` ${commandArgs.join(' ')}`;
}
terminal.sendText(command);
}
function ensureTerminal(path: string): vscode.Terminal {
let terminal: vscode.Terminal | undefined;
vscode
.window
.terminals
.forEach(t => {
if (t.name === terminalName) {
terminal = t;
}
});
if (!terminal) {
const terminalOptions: vscode.TerminalOptions = {
name: terminalName,
cwd: path
};
terminal = vscode.window.createTerminal(terminalOptions);
}
else {
terminal.sendText(['cd', `"${path}"`].join(' '), true);
}
return terminal;
}
export { executeCommand };
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).
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
}
Using source from this branch. I accidentally squashed the commit I was referencing and deleted the branch :(
settings.json
{
"terminal.integrated.defaultProfile.windows": "Git Bash"
}
@revrenlove maybe same my 1 year old issue not resolved yet? https://github.com/microsoft/vscode/issues/187804
with me it happen from Jun 2, 2023 when Git for Windows v2.41.0.windows.1 released. and still happen until today but no idea why, no workaround, and no fixes.
Now I am trying terminal.integrated.shellIntegration.enabled: false
hope it work.
I have a similar issue, i.e., sometimes, when switching from an open text file to the VSC terminal and starting to type, the first character does not show up. For example: git pull
becomes it pull
.
However: I only have this in VSC on Windows (currently on v1.90.2, but having this already for the last year or so).
I never have this when using VSC on MacOS.
My VSC settings are synced between both VSC instances, so the configuration should be (fairly) similar.
My terminal.*
settings in settings.json
are:
"terminal.integrated.defaultProfile.osx": "bash",
"terminal.integrated.defaultProfile.windows": "Git Bash",
"terminal.integrated.inheritEnv": false,
"terminal.integrated.scrollback": 5000,
"terminal.integrated.shellIntegration.enabled": false,
I have been observing this behaviour in VSCode on multiple Windows boxes for quite a long time also. On my local dev machine: VSCode v1.91.1, Git for Windows v2.45.2.
$ echo $PS1
\[\]\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$ \[\]
terminal.*
in settings.json
:
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.scrollback": 10000,
"terminal.integrated.defaultProfile.windows": "C:\\Program Files\\Git\\bin\\bash.exe (migrated)",
"terminal.integrated.profiles.windows": {
"C:\\Program Files\\Git\\bin\\bash.exe (migrated)": {
"path": "C:\\Program Files\\Git\\bin\\bash.exe",
"args": []
}
},
"terminal.integrated.commandsToSkipShell": [
"-workbench.action.quickOpenView"
],
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:
I would expect the command being sent to the terminal to be
cd ..
, but in the terminal (and only sometimes) it attempts to executed ..
- 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 (89de5a8d4d6205e5b11647eb6a74844ca23d2573, 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: enabledcanvas_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 ```