From f228971f77937c47eb535782dc46031308986ccb Mon Sep 17 00:00:00 2001 From: RGBCube Date: Thu, 19 Nov 2026 02:11:26 +0300 Subject: [PATCH] fix: don't try to print `undefined` when there are no suggestions previously: $ is complete "" node:internal/streams/writable:482 throw new ERR_INVALID_ARG_TYPE( ^ TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer, TypedArray, or DataView. Received undefined at _write (node:internal/streams/writable:482:13) at Writable.write (node:internal/streams/writable:510:10) at Command.action (file:///nix/store/51lvsyrhbad3d3985fks3y2vr9yhdnyy-inshellisense-0.0.4/lib/node_modules/@microsoft/inshellisense/build/commands/complete.js:11:20) { code: 'ERR_INVALID_ARG_TYPE' } Node.js v22.23.3 after this patch: $ is complete '' {"suggestions":[]} --- src/commands/complete.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/commands/complete.ts b/src/commands/complete.ts index a23b05c..72c7365 100644 --- a/src/commands/complete.ts +++ b/src/commands/complete.ts @@ -5,11 +5,12 @@ import os from "node:os"; import { Command } from "commander"; import { Shell } from "../utils/shell.js"; import { initializeRuntime } from "../runtime/initialize.js"; +import { SuggestionBlob } from "../runtime/model.js"; const action = async (input: string) => { const shell = os.platform() === "win32" ? Shell.Cmd : Shell.Bash; const { getSuggestions } = await initializeRuntime(shell); - const suggestions = await getSuggestions(input, process.cwd(), shell); + const suggestions: SuggestionBlob = (await getSuggestions(input, process.cwd(), shell)) ?? { suggestions: [] }; process.stdout.write(JSON.stringify(suggestions)); process.exit(0); };