mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
shortcut to open untitled editor (#279440)
This commit is contained in:
@@ -40,6 +40,7 @@ import { IChatWidgetService } from '../chat.js';
|
|||||||
import { CHAT_SETUP_ACTION_ID } from './chatActions.js';
|
import { CHAT_SETUP_ACTION_ID } from './chatActions.js';
|
||||||
import { CancellationToken } from '../../../../../base/common/cancellation.js';
|
import { CancellationToken } from '../../../../../base/common/cancellation.js';
|
||||||
import { PromptFileVariableKind, toPromptFileVariableEntry } from '../../common/chatVariableEntries.js';
|
import { PromptFileVariableKind, toPromptFileVariableEntry } from '../../common/chatVariableEntries.js';
|
||||||
|
import { NEW_CHAT_SESSION_ACTION_ID } from '../chatSessions/common.js';
|
||||||
|
|
||||||
export const enum ActionLocation {
|
export const enum ActionLocation {
|
||||||
ChatWidget = 'chatWidget',
|
ChatWidget = 'chatWidget',
|
||||||
@@ -197,25 +198,28 @@ export class ChatContinueInSessionActionItem extends ActionWidgetDropdownActionV
|
|||||||
class CreateRemoteAgentJobAction {
|
class CreateRemoteAgentJobAction {
|
||||||
constructor() { }
|
constructor() { }
|
||||||
|
|
||||||
|
private openUntitledEditor(commandService: ICommandService, continuationTarget: IChatSessionsExtensionPoint) {
|
||||||
|
commandService.executeCommand(`${NEW_CHAT_SESSION_ACTION_ID}.${continuationTarget.type}`);
|
||||||
|
}
|
||||||
|
|
||||||
async run(accessor: ServicesAccessor, continuationTarget: IChatSessionsExtensionPoint) {
|
async run(accessor: ServicesAccessor, continuationTarget: IChatSessionsExtensionPoint) {
|
||||||
const contextKeyService = accessor.get(IContextKeyService);
|
const contextKeyService = accessor.get(IContextKeyService);
|
||||||
const remoteJobCreatingKey = ChatContextKeys.remoteJobCreating.bindTo(contextKeyService);
|
const commandService = accessor.get(ICommandService);
|
||||||
|
|
||||||
try {
|
|
||||||
remoteJobCreatingKey.set(true);
|
|
||||||
|
|
||||||
const widgetService = accessor.get(IChatWidgetService);
|
const widgetService = accessor.get(IChatWidgetService);
|
||||||
const chatAgentService = accessor.get(IChatAgentService);
|
const chatAgentService = accessor.get(IChatAgentService);
|
||||||
const chatService = accessor.get(IChatService);
|
const chatService = accessor.get(IChatService);
|
||||||
const editorService = accessor.get(IEditorService);
|
const editorService = accessor.get(IEditorService);
|
||||||
|
|
||||||
|
const remoteJobCreatingKey = ChatContextKeys.remoteJobCreating.bindTo(contextKeyService);
|
||||||
|
|
||||||
|
try {
|
||||||
|
remoteJobCreatingKey.set(true);
|
||||||
|
|
||||||
const widget = widgetService.lastFocusedWidget;
|
const widget = widgetService.lastFocusedWidget;
|
||||||
if (!widget) {
|
if (!widget || !widget.viewModel) {
|
||||||
return;
|
return this.openUntitledEditor(commandService, continuationTarget);
|
||||||
}
|
|
||||||
if (!widget.viewModel) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo@connor4312: remove 'as' cast
|
// todo@connor4312: remove 'as' cast
|
||||||
const chatModel = widget.viewModel.model as ChatModel;
|
const chatModel = widget.viewModel.model as ChatModel;
|
||||||
if (!chatModel) {
|
if (!chatModel) {
|
||||||
@@ -227,8 +231,7 @@ class CreateRemoteAgentJobAction {
|
|||||||
let userPrompt = widget.getInput();
|
let userPrompt = widget.getInput();
|
||||||
if (!userPrompt) {
|
if (!userPrompt) {
|
||||||
if (!chatRequests.length) {
|
if (!chatRequests.length) {
|
||||||
// Nothing to do
|
return this.openUntitledEditor(commandService, continuationTarget);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
userPrompt = 'implement this.';
|
userPrompt = 'implement this.';
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user