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

Add progress indicator to Search #5980

Merged
merged 1 commit into from
Aug 20, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { MEMORY_TEXT } from './in-memory-text-resource';
import URI from '@theia/core/lib/common/uri';
import * as React from 'react';
import { SearchInWorkspacePreferences } from './search-in-workspace-preferences';
import { ProgressService } from '@theia/core';

const ROOT_ID = 'ResultTree';

Expand Down Expand Up @@ -117,6 +118,7 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget {
@inject(WorkspaceService) protected readonly workspaceService: WorkspaceService;
@inject(TreeExpansionService) protected readonly expansionService: TreeExpansionService;
@inject(SearchInWorkspacePreferences) protected readonly searchInWorkspacePreferences: SearchInWorkspacePreferences;
@inject(ProgressService) protected readonly progressService: ProgressService;

constructor(
@inject(TreeProps) readonly props: TreeProps,
Expand Down Expand Up @@ -207,6 +209,7 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget {
this.refreshModelChildren();
return;
}
const progress = await this.progressService.showProgress({ text: `search: ${searchTerm}`, options: { location: 'search' } });
const searchId = await this.searchService.search(searchTerm, {
onResult: (aSearchId: number, result: SearchInWorkspaceResult) => {
if (token.isCancellationRequested || aSearchId !== searchId) {
Expand Down Expand Up @@ -242,6 +245,7 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget {
}
},
onDone: () => {
progress.cancel();
if (token.isCancellationRequested) {
return;
}
Expand All @@ -257,6 +261,7 @@ export class SearchInWorkspaceResultTreeWidget extends TreeWidget {
}
}, searchOptions).catch(e => { return; });
token.onCancellationRequested(() => {
progress.cancel();
if (searchId) {
this.searchService.cancel(searchId);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ import * as ReactDOM from 'react-dom';
import { Event, Emitter, Disposable } from '@theia/core/lib/common';
import { WorkspaceService } from '@theia/workspace/lib/browser';
import { SearchInWorkspaceContextKeyService } from './search-in-workspace-context-key-service';
import { ProgressLocationService } from '@theia/core/lib/browser/progress-location-service';
import { ProgressBar } from '@theia/core/lib/browser/progress-bar';

export interface SearchFieldState {
className: string;
Expand Down Expand Up @@ -81,6 +83,9 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
@inject(SearchInWorkspaceContextKeyService)
protected readonly contextKeyService: SearchInWorkspaceContextKeyService;

@inject(ProgressLocationService)
protected readonly progressLocationService: ProgressLocationService;

@postConstruct()
protected init(): void {
this.id = SearchInWorkspaceWidget.ID;
Expand Down Expand Up @@ -139,6 +144,9 @@ export class SearchInWorkspaceWidget extends BaseWidget implements StatefulWidge
}));

this.toDispose.push(this.resultTreeWidget);

const onProgress = this.progressLocationService.onProgress('search');
this.toDispose.push(new ProgressBar({ container: this.node, insertMode: 'prepend' }, onProgress));
}

storeState(): object {
Expand Down
2 changes: 1 addition & 1 deletion packages/search-in-workspace/src/browser/styles/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

.t-siw-search-container {
color: var(--theia-ui-font-color1);
padding: 1px 5px;
padding: 5px ;
display: flex;
flex-direction: column;
height: 100%;
Expand Down