[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(search): arrow up key doesn't trigger search #1774

Merged
merged 3 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/search/__tests__/browser/search-history.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import { SearchHistory, SEARCH_WORD_SCOPE } from '../../src/browser/search-histo

class MockSearchServiceClient {
searchValue: string;
searchDebounce() {
// noop
}
}

class MockRecentStorage {
Expand Down Expand Up @@ -38,8 +41,10 @@ describe('测试 SearchHistory', () => {
});

test('method: setRecentSearchWord', () => {
const spy = jest.spyOn(searchServiceClient, 'searchDebounce');
searchHistory.setRecentSearchWord();
expect(searchServiceClient.searchValue).toEqual('d');
expect(spy).toHaveBeenCalled();
});

test('method: setRecentSearchWord 前进到底', () => {
Expand All @@ -55,8 +60,10 @@ describe('测试 SearchHistory', () => {
});

test('method: setBackRecentSearchWord', () => {
const spy = jest.spyOn(searchServiceClient, 'searchDebounce');
searchHistory.setBackRecentSearchWord();
expect(searchServiceClient.searchValue).toEqual('b');
expect(spy).toHaveBeenCalled();
});

test('method: setBackRecentSearchWord 后退到底', () => {
Expand Down
3 changes: 2 additions & 1 deletion packages/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"typings": "lib/index.d.ts",
"scripts": {
"prepublishOnly": "npm run build",
"build": "tsc --build ../../configs/ts/references/tsconfig.search.json"
"build": "tsc --build ../../configs/ts/references/tsconfig.search.json",
"watch": "npm run build -- -w"
},
"repository": {
"type": "git",
Expand Down
1 change: 1 addition & 0 deletions packages/search/src/browser/search-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export class SearchHistory {

private setSearchValue(value: string) {
this.searchServiceClient.searchValue = value;
this.searchServiceClient.searchDebounce();
}

reset() {
Expand Down
5 changes: 3 additions & 2 deletions packages/search/src/common/content-search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface IContentSearchServer {
*/
cancel(searchId: number): Promise<void>;

// dispose(): void;
dispose(): void;
}

export const IContentSearchClientService = Symbol('IContentSearchClientService');
Expand All @@ -80,7 +80,8 @@ export interface IContentSearchClientService {

validateMessage: ValidateMessage | undefined;

updateUIState(obj, e?: React.KeyboardEvent);
updateUIState(obj: Record<string, any>, e?: React.KeyboardEvent): void;
searchDebounce(): void;
}

export interface IUIState {
Expand Down
6 changes: 6 additions & 0 deletions packages/search/src/node/content-search.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,10 @@ export class ContentSearchService extends RPCService<IRPCContentSearchService> i
}
return args;
}

dispose(): void {
this.processMap.forEach((v) => {
v.dispose();
});
}
}