feat(core): Add trailing space when completing an at completion suggestion (#5475)
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
parent
b9fe4fc263
commit
d1bfba1abb
|
@ -7,7 +7,7 @@
|
|||
/** @vitest-environment jsdom */
|
||||
|
||||
import { describe, it, expect, beforeEach, vi, afterEach } from 'vitest';
|
||||
import { renderHook, act } from '@testing-library/react';
|
||||
import { renderHook, act, waitFor } from '@testing-library/react';
|
||||
import { useSlashCompletion } from './useSlashCompletion.js';
|
||||
import * as fs from 'fs/promises';
|
||||
import * as path from 'path';
|
||||
|
@ -136,7 +136,7 @@ describe('useSlashCompletion', () => {
|
|||
expect(result.current.isLoadingSuggestions).toBe(false);
|
||||
});
|
||||
|
||||
it('should reset all state to default values', () => {
|
||||
it('should reset all state to default values', async () => {
|
||||
const slashCommands = [
|
||||
{
|
||||
name: 'help',
|
||||
|
@ -165,6 +165,11 @@ describe('useSlashCompletion', () => {
|
|||
result.current.resetCompletionState();
|
||||
});
|
||||
|
||||
// Wait for async suggestions clearing
|
||||
await waitFor(() => {
|
||||
expect(result.current.suggestions).toEqual([]);
|
||||
});
|
||||
|
||||
expect(result.current.suggestions).toEqual([]);
|
||||
expect(result.current.activeSuggestionIndex).toBe(-1);
|
||||
expect(result.current.visibleStartIndex).toBe(0);
|
||||
|
|
|
@ -111,7 +111,7 @@ export function useSlashCompletion(
|
|||
|
||||
useEffect(() => {
|
||||
if (commandIndex === -1 || reverseSearchActive) {
|
||||
resetCompletionState();
|
||||
setTimeout(resetCompletionState, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -631,17 +631,17 @@ export function useSlashCompletion(
|
|||
) {
|
||||
suggestionText = ' ' + suggestionText;
|
||||
}
|
||||
suggestionText += ' ';
|
||||
}
|
||||
|
||||
suggestionText += ' ';
|
||||
|
||||
buffer.replaceRangeByOffset(
|
||||
logicalPosToOffset(buffer.lines, cursorRow, completionStart.current),
|
||||
logicalPosToOffset(buffer.lines, cursorRow, completionEnd.current),
|
||||
suggestionText,
|
||||
);
|
||||
resetCompletionState();
|
||||
},
|
||||
[cursorRow, resetCompletionState, buffer, suggestions, commandIndex],
|
||||
[cursorRow, buffer, suggestions, commandIndex],
|
||||
);
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue