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: don't show inline chat hint in search editor #192614

Merged
merged 1 commit into from
Sep 8, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibil
import { Registry } from 'vs/platform/registry/common/platform';
import { Extensions, IConfigurationMigrationRegistry } from 'vs/workbench/common/configuration';
import { LOG_MODE_ID, OUTPUT_MODE_ID } from 'vs/workbench/services/output/common/output';
import { SEARCH_RESULT_LANGUAGE_ID } from 'vs/workbench/services/search/common/search';

const $ = dom.$;

Expand Down Expand Up @@ -97,10 +98,10 @@ export class EmptyTextEditorHintContribution implements IEditorContribution {

const inlineChatProviders = [...this.inlineChatService.getAllProvider()];
const languageId = model?.getLanguageId();
const shouldRenderInlineChatHint = !this.editor.getOption(EditorOption.readOnly) && languageId !== OUTPUT_MODE_ID && languageId !== LOG_MODE_ID && inlineChatProviders.length > 0;
const shouldRenderDefaultHint = languageId === PLAINTEXT_LANGUAGE_ID && !inlineChatProviders.length;
const shouldRenderInlineChatHint = !this.editor.getOption(EditorOption.readOnly) && languageId !== OUTPUT_MODE_ID && languageId !== LOG_MODE_ID && languageId !== SEARCH_RESULT_LANGUAGE_ID && inlineChatProviders.length > 0;
const shouldRenderDefaultHint = model?.uri.scheme === Schemas.untitled && languageId === PLAINTEXT_LANGUAGE_ID && !inlineChatProviders.length;

if (model && (model.uri.scheme === Schemas.untitled && shouldRenderDefaultHint || shouldRenderInlineChatHint) && configValue !== 'hidden') {
if ((shouldRenderDefaultHint || shouldRenderInlineChatHint) && configValue !== 'hidden') {
this.textHintContentWidget = new EmptyTextEditorHintContentWidget(
this.editor,
this.editorGroupsService,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { createTextBufferFactoryFromStream } from 'vs/editor/common/model/textMo
import { SearchEditorWorkingCopyTypeId } from 'vs/workbench/contrib/searchEditor/browser/constants';
import { Emitter } from 'vs/base/common/event';
import { ResourceMap } from 'vs/base/common/map';
import { SEARCH_RESULT_LANGUAGE_ID } from 'vs/workbench/services/search/common/search';

export type SearchEditorData = { resultsModel: ITextModel; configurationModel: SearchConfigurationModel };

Expand Down Expand Up @@ -65,7 +66,7 @@ class SearchEditorModelFactory {
}

return Promise.resolve({
resultsModel: modelService.getModel(resource) ?? modelService.createModel('', languageService.createById('search-result'), resource),
resultsModel: modelService.getModel(resource) ?? modelService.createModel('', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
configurationModel: new SearchConfigurationModel(config)
});
})();
Expand Down Expand Up @@ -98,7 +99,7 @@ class SearchEditorModelFactory {
}

return Promise.resolve({
resultsModel: modelService.createModel(contents ?? '', languageService.createById('search-result'), resource),
resultsModel: modelService.createModel(contents ?? '', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
configurationModel: new SearchConfigurationModel(config)
});
})();
Expand Down Expand Up @@ -132,7 +133,7 @@ class SearchEditorModelFactory {

const { text, config } = await instantiationService.invokeFunction(parseSavedSearchEditor, existingFile);
return ({
resultsModel: modelService.createModel(text ?? '', languageService.createById('search-result'), resource),
resultsModel: modelService.createModel(text ?? '', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
configurationModel: new SearchConfigurationModel(config)
});
})();
Expand All @@ -149,15 +150,15 @@ class SearchEditorModelFactory {
if (!model && backup) {
const factory = await createTextBufferFactoryFromStream(backup.value);

model = modelService.createModel(factory, languageService.createById('search-result'), resource);
model = modelService.createModel(factory, languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource);
}

if (model) {
const existingFile = model.getValue();
const { text, config } = parseSerializedSearchEditor(existingFile);
modelService.destroyModel(resource);
return ({
resultsModel: modelService.createModel(text ?? '', languageService.createById('search-result'), resource),
resultsModel: modelService.createModel(text ?? '', languageService.createById(SEARCH_RESULT_LANGUAGE_ID), resource),
configurationModel: new SearchConfigurationModel(config)
});
}
Expand Down
1 change: 1 addition & 0 deletions src/vs/workbench/services/search/common/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export { TextSearchCompleteMessageType };
export const VIEWLET_ID = 'workbench.view.search';
export const PANEL_ID = 'workbench.panel.search';
export const VIEW_ID = 'workbench.view.search';
export const SEARCH_RESULT_LANGUAGE_ID = 'search-result';

export const SEARCH_EXCLUDE_CONFIG = 'search.exclude';

Expand Down
4 changes: 2 additions & 2 deletions src/vs/workbench/services/search/common/searchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { IUriIdentityService } from 'vs/platform/uriIdentity/common/uriIdentity'
import { EditorResourceAccessor, SideBySideEditor } from 'vs/workbench/common/editor';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
import { deserializeSearchError, FileMatch, ICachedSearchStats, IFileMatch, IFileQuery, IFileSearchStats, IFolderQuery, IProgressMessage, ISearchComplete, ISearchEngineStats, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, isFileMatch, isProgressMessage, ITextQuery, pathIncludedInQuery, QueryType, SearchError, SearchErrorCode, SearchProviderType } from 'vs/workbench/services/search/common/search';
import { deserializeSearchError, FileMatch, ICachedSearchStats, IFileMatch, IFileQuery, IFileSearchStats, IFolderQuery, IProgressMessage, ISearchComplete, ISearchEngineStats, ISearchProgressItem, ISearchQuery, ISearchResultProvider, ISearchService, isFileMatch, isProgressMessage, ITextQuery, pathIncludedInQuery, QueryType, SEARCH_RESULT_LANGUAGE_ID, SearchError, SearchErrorCode, SearchProviderType } from 'vs/workbench/services/search/common/search';
import { addContextToEditorMatches, editorMatchesToTextSearchResults } from 'vs/workbench/services/search/common/searchHelpers';

export class SearchService extends Disposable implements ISearchService {
Expand Down Expand Up @@ -462,7 +462,7 @@ export class SearchService extends Disposable implements ISearchService {
}

// Skip search results
if (model.getLanguageId() === 'search-result' && !(query.includePattern && query.includePattern['**/*.code-search'])) {
if (model.getLanguageId() === SEARCH_RESULT_LANGUAGE_ID && !(query.includePattern && query.includePattern['**/*.code-search'])) {
// TODO: untitled search editors will be excluded from search even when include *.code-search is specified
return;
}
Expand Down