提交 0b27d444 编写于 作者: R Rob Lourens

Show search result count UI - Fix #6669

上级 d759bb70
......@@ -72,7 +72,7 @@
.search-viewlet .query-details {
min-height: 1em;
position: relative;
margin: 0 0 6px 17px;
margin: 0 0 0 17px;
}
.search-viewlet .query-details .more {
......@@ -107,7 +107,7 @@
}
.search-viewlet .query-details.more .file-types:last-child {
padding-bottom: 4px;
padding-bottom: 10px;
}
.search-viewlet .query-details .search-pattern-info {
......@@ -146,11 +146,13 @@
.search-viewlet .message {
padding-left: 22px;
padding-right: 22px;
padding-top: 2px;
padding-top: 0px;
}
.search-viewlet .message p:first-child {
margin-top: 0;
margin-top: 0px;
margin-bottom: 0px;
padding-bottom: 4px;
}
.search-viewlet .filematch {
......
......@@ -720,7 +720,10 @@ export class SearchViewlet extends Viewlet {
this.inputPatternIncludes.setWidth(this.size.width - 28 /* container margin */);
this.inputPatternGlobalExclusions.width = this.size.width - 28 /* container margin */ - 24 /* actions */;
let searchResultContainerSize = this.size.height - dom.getTotalHeight(this.searchWidgetsContainer.getContainer()) - 6 /** container margin top */;
let searchResultContainerSize = this.size.height -
dom.getTotalHeight(this.messages.getHTMLElement()) -
dom.getTotalHeight(this.searchWidgetsContainer.getContainer());
this.results.style({ height: searchResultContainerSize + 'px' });
this.tree.layout(searchResultContainerSize);
......@@ -1113,14 +1116,22 @@ export class SearchViewlet extends Viewlet {
}
// Search result tree update
let count = this.viewModel.searchResult.fileCount();
if (visibleMatches !== count) {
visibleMatches = count;
const fileCount = this.viewModel.searchResult.fileCount();
if (visibleMatches !== fileCount) {
visibleMatches = fileCount;
this.tree.refresh().then(() => {
autoExpand(false);
}).done(null, errors.onUnexpectedError);
// Update results text
const msgWasHidden = this.messages.isHidden();
const div = this.clearMessage();
$(div).p({ text: this.buildResultCountMessage(this.viewModel.searchResult.count(), fileCount) });
if (msgWasHidden) {
this.reLayout();
}
}
if (count > 0) {
if (fileCount > 0) {
// since we have results now, enable some actions
if (!this.actionRegistry['vs.tree.collapse'].enabled) {
this.actionRegistry['vs.tree.collapse'].enabled = true;
......@@ -1133,6 +1144,18 @@ export class SearchViewlet extends Viewlet {
this.viewModel.search(query).done(onComplete, onError, onProgress);
}
private buildResultCountMessage(resultCount: number, fileCount: number): string {
if (resultCount === 1 && fileCount === 1) {
return nls.localize('search.file.result', "Found {0} result in {1} file", resultCount, fileCount);
} else if (resultCount === 1) {
return nls.localize('search.files.result', "Found {0} result in {1} files", resultCount, fileCount);
} else if (fileCount === 1) {
return nls.localize('search.file.results', "Found {0} results in {1} file", resultCount, fileCount);
} else {
return nls.localize('search.files.results', "Found {0} results in {1} files", resultCount, fileCount);
}
}
private searchWithoutFolderMessage(div: Builder): void {
$(div).p({ text: nls.localize('searchWithoutFolder', "You have not yet opened a folder. Only open files are currently searched - ") })
.asContainer().a({
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册