mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
chore - move isInteractiveEditorOptions into its type
This commit is contained in:
@@ -21,15 +21,12 @@ import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/commo
|
||||
import { IEditorService, SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IUntitledTextResourceEditorInput } from 'vs/workbench/common/editor';
|
||||
import { ICodeEditorService } from 'vs/editor/browser/services/codeEditorService';
|
||||
import { Range } from 'vs/editor/common/core/range';
|
||||
import { Selection } from 'vs/editor/common/core/selection';
|
||||
import { fromNow } from 'vs/base/common/date';
|
||||
import { IInlineChatSessionService, Recording } from 'vs/workbench/contrib/inlineChat/browser/inlineChatSession';
|
||||
import { runAccessibilityHelpAction } from 'vs/workbench/contrib/chat/browser/actions/chatAccessibilityHelp';
|
||||
import { CONTEXT_ACCESSIBILITY_MODE_ENABLED } from 'vs/platform/accessibility/common/accessibility';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { CommandsRegistry } from 'vs/platform/commands/common/commands';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { AccessibilityHelpAction } from 'vs/workbench/contrib/accessibility/browser/accessibleViewActions';
|
||||
|
||||
@@ -52,23 +49,11 @@ export class StartSessionAction extends EditorAction2 {
|
||||
});
|
||||
}
|
||||
|
||||
private _isInteractivEditorOptions(options: any): options is InlineChatRunOptions {
|
||||
const { initialSelection, initialRange, message, autoSend, position } = options;
|
||||
if (
|
||||
typeof message !== 'undefined' && typeof message !== 'string'
|
||||
|| typeof autoSend !== 'undefined' && typeof autoSend !== 'boolean'
|
||||
|| typeof initialRange !== 'undefined' && !Range.isIRange(initialRange)
|
||||
|| typeof initialSelection !== 'undefined' && !Selection.isISelection(initialSelection)
|
||||
|| typeof position !== 'undefined' && !Position.isIPosition(position)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
override runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor, ..._args: any[]) {
|
||||
let options: InlineChatRunOptions | undefined;
|
||||
const arg = _args[0];
|
||||
if (arg && this._isInteractivEditorOptions(arg)) {
|
||||
if (arg && InlineChatRunOptions.isInteractiveEditorOptions(arg)) {
|
||||
options = arg;
|
||||
}
|
||||
InlineChatController.get(editor)?.run(options);
|
||||
|
||||
@@ -38,7 +38,7 @@ import { Lazy } from 'vs/base/common/lazy';
|
||||
import { Progress } from 'vs/platform/progress/common/progress';
|
||||
import { generateUuid } from 'vs/base/common/uuid';
|
||||
import { TextEdit } from 'vs/editor/common/languages';
|
||||
import { ISelection } from 'vs/editor/common/core/selection';
|
||||
import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
export const enum State {
|
||||
@@ -64,7 +64,7 @@ const enum Message {
|
||||
RERUN_INPUT = 1 << 6,
|
||||
}
|
||||
|
||||
export interface InlineChatRunOptions {
|
||||
export abstract class InlineChatRunOptions {
|
||||
initialSelection?: ISelection;
|
||||
initialRange?: IRange;
|
||||
message?: string;
|
||||
@@ -72,6 +72,19 @@ export interface InlineChatRunOptions {
|
||||
existingSession?: Session;
|
||||
isUnstashed?: boolean;
|
||||
position?: IPosition;
|
||||
|
||||
static isInteractiveEditorOptions(options: any): options is InlineChatRunOptions {
|
||||
const { initialSelection, initialRange, message, autoSend, position } = options;
|
||||
if (
|
||||
typeof message !== 'undefined' && typeof message !== 'string'
|
||||
|| typeof autoSend !== 'undefined' && typeof autoSend !== 'boolean'
|
||||
|| typeof initialRange !== 'undefined' && !Range.isIRange(initialRange)
|
||||
|| typeof initialSelection !== 'undefined' && !Selection.isISelection(initialSelection)
|
||||
|| typeof position !== 'undefined' && !Position.isIPosition(position)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
export class InlineChatController implements IEditorContribution {
|
||||
|
||||
Reference in New Issue
Block a user