mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-23 11:34:44 -07:00
fix(ui): restrict space-suppression logic to SLASH mode only
This commit is contained in:
@@ -582,6 +582,33 @@ describe('useCommandCompletion', () => {
|
|||||||
|
|
||||||
expect(result.current.textBuffer.text).toBe('@src\\components\\');
|
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', () => {
|
describe('prompt completion filtering', () => {
|
||||||
|
|||||||
@@ -362,12 +362,16 @@ export function useCommandCompletion({
|
|||||||
const lineCodePoints = toCodePoints(buffer.lines[cursorRow] || '');
|
const lineCodePoints = toCodePoints(buffer.lines[cursorRow] || '');
|
||||||
const charAfterCompletion = lineCodePoints[end];
|
const charAfterCompletion = lineCodePoints[end];
|
||||||
|
|
||||||
const command = slashCompletionRange.getCommandFromSuggestion(suggestion);
|
let shouldAddSpace = true;
|
||||||
// Don't add a space if the command has an action (can be executed)
|
if (completionMode === CompletionMode.SLASH) {
|
||||||
// and doesn't have a completion function (doesn't REQUIRE more arguments)
|
const command =
|
||||||
const isExecutableCommand = !!(command && command.action);
|
slashCompletionRange.getCommandFromSuggestion(suggestion);
|
||||||
const requiresArguments = !!(command && command.completion);
|
// Don't add a space if the command has an action (can be executed)
|
||||||
const shouldAddSpace = !isExecutableCommand || requiresArguments;
|
// 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 (
|
if (
|
||||||
charAfterCompletion !== ' ' &&
|
charAfterCompletion !== ' ' &&
|
||||||
|
|||||||
@@ -2131,30 +2131,9 @@ THE SOFTWARE.
|
|||||||
|
|
||||||
============================================================
|
============================================================
|
||||||
path-to-regexp@6.3.0
|
path-to-regexp@6.3.0
|
||||||
(https://github.com/pillarjs/path-to-regexp.git)
|
(No repository found)
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
|
License text not found.
|
||||||
|
|
||||||
============================================================
|
============================================================
|
||||||
send@1.2.1
|
send@1.2.1
|
||||||
|
|||||||
Reference in New Issue
Block a user