mirror of https://github.com/microsoft/vscode.git
reduce amount of file changes
This commit is contained in:
parent
fa7eec5007
commit
f2732a1c49
|
@ -3,9 +3,9 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { URI } from '../../../base/common/uri.js';
|
||||
import { Event } from '../../../base/common/event.js';
|
||||
import { IDisposable } from '../../../base/common/lifecycle.js';
|
||||
import { URI } from '../../../base/common/uri.js';
|
||||
import { createDecorator } from '../../instantiation/common/instantiation.js';
|
||||
import { IWorkspace, ISingleFolderWorkspaceIdentifier, IWorkspaceIdentifier } from '../../workspace/common/workspace.js';
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ import { isLinux, isWindows } from '../../../../../../base/common/platform.js';
|
|||
import { ILabelService } from '../../../../../../platform/label/common/label.js';
|
||||
import { IOpenerService } from '../../../../../../platform/opener/common/opener.js';
|
||||
import { basename, dirname, extUri } from '../../../../../../base/common/resources.js';
|
||||
import { IPromptPath, IPromptsService } from '../../../common/promptSyntax/service/types.js';
|
||||
import { IPrompt, IPromptsService } from '../../../common/promptSyntax/service/types.js';
|
||||
import { DOCUMENTATION_URL, PROMPT_FILE_EXTENSION } from '../../../common/promptSyntax/constants.js';
|
||||
import { IInstantiationService } from '../../../../../../platform/instantiation/common/instantiation.js';
|
||||
import { IPickOptions, IQuickInputService, IQuickPickItem } from '../../../../../../platform/quickinput/common/quickInput.js';
|
||||
|
@ -63,7 +63,7 @@ interface IPromptSelectionResult {
|
|||
* Creates a quick pick item for a prompt.
|
||||
*/
|
||||
const createPickItem = (
|
||||
{ uri }: IPromptPath,
|
||||
{ uri }: IPrompt,
|
||||
labelService: ILabelService,
|
||||
): WithUriValue<IQuickPickItem> => {
|
||||
const fileBasename = basename(uri);
|
||||
|
|
|
@ -7,11 +7,11 @@ import { localize } from '../../../../../../../nls.js';
|
|||
import { createPromptFile } from './utils/createPromptFile.js';
|
||||
import { CHAT_CATEGORY } from '../../../actions/chatActions.js';
|
||||
import { askForPromptName } from './dialogs/askForPromptName.js';
|
||||
import { askForPromptFolder } from './dialogs/askForPromptLocation.js';
|
||||
import { askForPromptSourceFolder } from './dialogs/askForPromptSourceFolder.js';
|
||||
import { IFileService } from '../../../../../../../platform/files/common/files.js';
|
||||
import { ILabelService } from '../../../../../../../platform/label/common/label.js';
|
||||
import { IOpenerService } from '../../../../../../../platform/opener/common/opener.js';
|
||||
import { IPromptPath, IPromptsService } from '../../../../common/promptSyntax/service/types.js';
|
||||
import { IPrompt, IPromptsService } from '../../../../common/promptSyntax/service/types.js';
|
||||
import { appendToCommandPalette } from '../../../../../files/browser/fileActions.contribution.js';
|
||||
import { IQuickInputService } from '../../../../../../../platform/quickinput/common/quickInput.js';
|
||||
import { ServicesAccessor } from '../../../../../../../platform/instantiation/common/instantiation.js';
|
||||
|
@ -48,7 +48,7 @@ const GLOBAL_COMMAND_TITLE = localize('commands.prompts.create.title.global', "C
|
|||
*/
|
||||
const command = async (
|
||||
accessor: ServicesAccessor,
|
||||
type: IPromptPath['type'],
|
||||
type: IPrompt['type'],
|
||||
): Promise<void> => {
|
||||
const fileService = accessor.get(IFileService);
|
||||
const labelService = accessor.get(ILabelService);
|
||||
|
@ -62,7 +62,7 @@ const command = async (
|
|||
return;
|
||||
}
|
||||
|
||||
const selectedFolder = await askForPromptFolder({
|
||||
const selectedFolder = await askForPromptSourceFolder({
|
||||
type: type,
|
||||
labelService,
|
||||
openerService,
|
||||
|
|
|
@ -10,14 +10,14 @@ import { WithUriValue } from '../../../../../../../../base/common/types.js';
|
|||
import { DOCUMENTATION_URL } from '../../../../../common/promptSyntax/constants.js';
|
||||
import { ILabelService } from '../../../../../../../../platform/label/common/label.js';
|
||||
import { IOpenerService } from '../../../../../../../../platform/opener/common/opener.js';
|
||||
import { IPromptPath, IPromptsService } from '../../../../../common/promptSyntax/service/types.js';
|
||||
import { IPrompt, IPromptsService } from '../../../../../common/promptSyntax/service/types.js';
|
||||
import { IWorkspaceContextService } from '../../../../../../../../platform/workspace/common/workspace.js';
|
||||
import { IPickOptions, IQuickInputService, IQuickPickItem } from '../../../../../../../../platform/quickinput/common/quickInput.js';
|
||||
|
||||
/**
|
||||
* Options for {@link askForPromptFolder} dialog.
|
||||
* Options for {@link askForPromptSourceFolder} dialog.
|
||||
*/
|
||||
interface IAskForPromptFolderOptions {
|
||||
interface IAskForFolderOptions {
|
||||
/**
|
||||
* Prompt type.
|
||||
*/
|
||||
|
@ -34,8 +34,8 @@ interface IAskForPromptFolderOptions {
|
|||
* Asks the user for a specific prompt folder, if multiple folders provided.
|
||||
* Returns immediately if only one folder available.
|
||||
*/
|
||||
export const askForPromptFolder = async (
|
||||
options: IAskForPromptFolderOptions,
|
||||
export const askForPromptSourceFolder = async (
|
||||
options: IAskForFolderOptions,
|
||||
): Promise<URI | undefined> => {
|
||||
const { type, promptsService, quickInputService, labelService, openerService, workspaceService } = options;
|
||||
|
||||
|
@ -146,7 +146,7 @@ interface ILabels {
|
|||
* when in a single-root workspace.
|
||||
*/
|
||||
const createSingleRootWorkspaceLabels = (
|
||||
{ uri }: IPromptPath,
|
||||
{ uri }: IPrompt,
|
||||
labelService: ILabelService,
|
||||
): ILabels => {
|
||||
return {
|
||||
|
@ -160,7 +160,7 @@ const createSingleRootWorkspaceLabels = (
|
|||
* when in a multi-root workspace.
|
||||
*/
|
||||
const createMultiRootWorkspaceLabels = (
|
||||
{ uri }: IPromptPath,
|
||||
{ uri }: IPrompt,
|
||||
labelService: ILabelService,
|
||||
): ILabels => {
|
||||
// TODO: @legomushroom - fix multi-root workspace labels
|
|
@ -3,7 +3,7 @@
|
|||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { IPromptPath, IPromptsService } from './types.js';
|
||||
import { IPrompt, IPromptsService } from './types.js';
|
||||
import { URI } from '../../../../../../base/common/uri.js';
|
||||
import { assert } from '../../../../../../base/common/assert.js';
|
||||
import { PromptFilesLocator } from '../utils/promptFilesLocator.js';
|
||||
|
@ -81,7 +81,7 @@ export class PromptsService extends Disposable implements IPromptsService {
|
|||
return this.cache.get(model);
|
||||
}
|
||||
|
||||
public async listPromptFiles(): Promise<readonly IPromptPath[]> {
|
||||
public async listPromptFiles(): Promise<readonly IPrompt[]> {
|
||||
const globalLocations = [this.userDataService.currentProfile.promptsHome];
|
||||
|
||||
const prompts = await Promise.all([
|
||||
|
@ -95,8 +95,8 @@ export class PromptsService extends Disposable implements IPromptsService {
|
|||
}
|
||||
|
||||
public getSourceFolders(
|
||||
type: IPromptPath['type'],
|
||||
): readonly IPromptPath[] {
|
||||
type: IPrompt['type'],
|
||||
): readonly IPrompt[] {
|
||||
// sanity check to make sure we don't miss a new prompt type
|
||||
// added in the future
|
||||
assert(
|
||||
|
@ -106,7 +106,7 @@ export class PromptsService extends Disposable implements IPromptsService {
|
|||
|
||||
const prompts = (type === 'global')
|
||||
? [this.userDataService.currentProfile.promptsHome]
|
||||
: this.fileLocator.getConfigBasedLocations();
|
||||
: this.fileLocator.getSourceLocations();
|
||||
|
||||
return prompts.map(addType(type));
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ export class PromptsService extends Disposable implements IPromptsService {
|
|||
*/
|
||||
const addType = (
|
||||
type: 'local' | 'global',
|
||||
): (uri: URI) => IPromptPath => {
|
||||
): (uri: URI) => IPrompt => {
|
||||
return (uri) => {
|
||||
return { uri, type: type };
|
||||
};
|
||||
|
@ -128,7 +128,7 @@ const addType = (
|
|||
*/
|
||||
const withType = (
|
||||
type: 'local' | 'global',
|
||||
): (uris: readonly URI[]) => (readonly IPromptPath[]) => {
|
||||
): (uris: readonly URI[]) => (readonly IPrompt[]) => {
|
||||
return (uris) => {
|
||||
return uris
|
||||
.map(addType(type));
|
||||
|
|
|
@ -25,7 +25,7 @@ type TPromptsType = 'local' | 'global';
|
|||
* Represents a prompt path with its type.
|
||||
* This is used for both prompt files and prompt source folders.
|
||||
*/
|
||||
export interface IPromptPath {
|
||||
export interface IPrompt {
|
||||
/**
|
||||
* URI of the prompt.
|
||||
*/
|
||||
|
@ -54,10 +54,10 @@ export interface IPromptsService extends IDisposable {
|
|||
/**
|
||||
* List all available prompt files.
|
||||
*/
|
||||
listPromptFiles(): Promise<readonly IPromptPath[]>;
|
||||
listPromptFiles(): Promise<readonly IPrompt[]>;
|
||||
|
||||
/**
|
||||
* Get a list of prompt source folders based on the provided prompt type.
|
||||
*/
|
||||
getSourceFolders(type: TPromptsType): readonly IPromptPath[];
|
||||
getSourceFolders(type: TPromptsType): readonly IPrompt[];
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ export class PromptFilesLocator {
|
|||
exclude: readonly URI[],
|
||||
): Promise<readonly URI[]> {
|
||||
return await this.listFilesIn(
|
||||
this.getConfigBasedLocations(),
|
||||
this.getSourceLocations(),
|
||||
exclude,
|
||||
);
|
||||
}
|
||||
|
@ -69,7 +69,7 @@ export class PromptFilesLocator {
|
|||
*
|
||||
* @returns List of possible prompt file locations.
|
||||
*/
|
||||
public getConfigBasedLocations(): readonly URI[] {
|
||||
public getSourceLocations(): readonly URI[] {
|
||||
const paths = new ResourceSet();
|
||||
const sourceLocations = PromptFilesConfig.sourceLocations(this.configService);
|
||||
|
||||
|
|
Loading…
Reference in New Issue