From a0f609d2d95315525032cba794ccfb107da499ce Mon Sep 17 00:00:00 2001 From: Keith Guerin Date: Fri, 27 Feb 2026 14:19:21 -0800 Subject: [PATCH] fix(ui): restrict space-suppression logic to SLASH mode only --- .../ui/hooks/useCommandCompletion.test.tsx | 27 +++++++++++++++++++ .../cli/src/ui/hooks/useCommandCompletion.tsx | 16 ++++++----- packages/vscode-ide-companion/NOTICES.txt | 25 ++--------------- 3 files changed, 39 insertions(+), 29 deletions(-) diff --git a/packages/cli/src/ui/hooks/useCommandCompletion.test.tsx b/packages/cli/src/ui/hooks/useCommandCompletion.test.tsx index 2d20100d0e..5cc7077351 100644 --- a/packages/cli/src/ui/hooks/useCommandCompletion.test.tsx +++ b/packages/cli/src/ui/hooks/useCommandCompletion.test.tsx @@ -582,6 +582,33 @@ describe('useCommandCompletion', () => { expect(result.current.textBuffer.text).toBe('@src\\components\\'); }); + + it('should ADD a space for AT completion even if name matches a command with an action', async () => { + // Setup a mock where getCommandFromSuggestion WOULD return a command with an action + // if it were in SLASH mode. + setupMocks({ + atSuggestions: [{ label: 'memory', value: 'memory' }], + slashCompletionRange: { + completionStart: 0, + completionEnd: 0, + getCommandFromSuggestion: () => + ({ action: vi.fn() }) as unknown as SlashCommand, + }, + }); + + const { result } = renderCommandCompletionHook('@mem'); + + await waitFor(() => { + expect(result.current.suggestions.length).toBe(1); + }); + + act(() => { + result.current.handleAutocomplete(0); + }); + + // Should have a space because it's AT mode, not SLASH mode + expect(result.current.textBuffer.text).toBe('@memory '); + }); }); describe('prompt completion filtering', () => { diff --git a/packages/cli/src/ui/hooks/useCommandCompletion.tsx b/packages/cli/src/ui/hooks/useCommandCompletion.tsx index 4674e2a188..967266e835 100644 --- a/packages/cli/src/ui/hooks/useCommandCompletion.tsx +++ b/packages/cli/src/ui/hooks/useCommandCompletion.tsx @@ -362,12 +362,16 @@ export function useCommandCompletion({ const lineCodePoints = toCodePoints(buffer.lines[cursorRow] || ''); const charAfterCompletion = lineCodePoints[end]; - const command = slashCompletionRange.getCommandFromSuggestion(suggestion); - // Don't add a space if the command has an action (can be executed) - // and doesn't have a completion function (doesn't REQUIRE more arguments) - const isExecutableCommand = !!(command && command.action); - const requiresArguments = !!(command && command.completion); - const shouldAddSpace = !isExecutableCommand || requiresArguments; + let shouldAddSpace = true; + if (completionMode === CompletionMode.SLASH) { + const command = + slashCompletionRange.getCommandFromSuggestion(suggestion); + // Don't add a space if the command has an action (can be executed) + // and doesn't have a completion function (doesn't REQUIRE more arguments) + const isExecutableCommand = !!(command && command.action); + const requiresArguments = !!(command && command.completion); + shouldAddSpace = !isExecutableCommand || requiresArguments; + } if ( charAfterCompletion !== ' ' && diff --git a/packages/vscode-ide-companion/NOTICES.txt b/packages/vscode-ide-companion/NOTICES.txt index 83e1d959cc..5337fb3ef6 100644 --- a/packages/vscode-ide-companion/NOTICES.txt +++ b/packages/vscode-ide-companion/NOTICES.txt @@ -2131,30 +2131,9 @@ THE SOFTWARE. ============================================================ path-to-regexp@6.3.0 -(https://github.com/pillarjs/path-to-regexp.git) - -The MIT License (MIT) - -Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com) - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. +(No repository found) +License text not found. ============================================================ send@1.2.1