mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
move feeback commands into into their own toolbar to the side
This commit is contained in:
parent
670f92f22b
commit
fd05c6b56a
|
@ -10,7 +10,7 @@ import { EditorAction2 } from 'vs/editor/browser/editorExtensions';
|
|||
import { EmbeddedCodeEditorWidget, EmbeddedDiffEditorWidget } from 'vs/editor/browser/widget/embeddedCodeEditorWidget';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { InteractiveEditorController, InteractiveEditorRunOptions } from 'vs/workbench/contrib/interactiveEditor/browser/interactiveEditorController';
|
||||
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST, CTX_INTERACTIVE_EDITOR_HAS_PROVIDER, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, CTX_INTERACTIVE_EDITOR_EMPTY, CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION, CTX_INTERACTIVE_EDITOR_VISIBLE, MENU_INTERACTIVE_EDITOR_WIDGET, MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK, CTX_INTERACTIVE_EDITOR_SHOWING_DIFF, CTX_INTERACTIVE_EDITOR_EDIT_MODE, EditMode, CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE, CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED, CTX_INTERACTIVE_EDITOR_DID_EDIT, CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor';
|
||||
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_HAS_ACTIVE_REQUEST, CTX_INTERACTIVE_EDITOR_HAS_PROVIDER, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, CTX_INTERACTIVE_EDITOR_EMPTY, CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION, CTX_INTERACTIVE_EDITOR_VISIBLE, MENU_INTERACTIVE_EDITOR_WIDGET, MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK, CTX_INTERACTIVE_EDITOR_SHOWING_DIFF, CTX_INTERACTIVE_EDITOR_EDIT_MODE, EditMode, CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE, CTX_INTERACTIVE_EDITOR_DOCUMENT_CHANGED, CTX_INTERACTIVE_EDITOR_DID_EDIT, CTX_INTERACTIVE_EDITOR_HAS_STASHED_SESSION, MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IAction2Options, MenuRegistry } from 'vs/platform/actions/common/actions';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
|
@ -377,7 +377,7 @@ export class FeebackHelpfulCommand extends AbstractInteractiveEditorAction {
|
|||
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
|
||||
toggled: CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK.isEqualTo('helpful'),
|
||||
menu: {
|
||||
id: MENU_INTERACTIVE_EDITOR_WIDGET_STATUS,
|
||||
id: MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK,
|
||||
when: CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.notEqualsTo(undefined),
|
||||
group: '2_feedback',
|
||||
order: 1
|
||||
|
@ -399,7 +399,7 @@ export class FeebackUnhelpfulCommand extends AbstractInteractiveEditorAction {
|
|||
precondition: CTX_INTERACTIVE_EDITOR_VISIBLE,
|
||||
toggled: CTX_INTERACTIVE_EDITOR_LAST_FEEDBACK.isEqualTo('unhelpful'),
|
||||
menu: {
|
||||
id: MENU_INTERACTIVE_EDITOR_WIDGET_STATUS,
|
||||
id: MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK,
|
||||
when: CTX_INTERACTIVE_EDITOR_LAST_RESPONSE_TYPE.notEqualsTo(undefined),
|
||||
group: '2_feedback',
|
||||
order: 2
|
||||
|
|
|
@ -326,11 +326,11 @@ export class LiveStrategy extends EditModeStrategy {
|
|||
}
|
||||
let message: string;
|
||||
if (linesChanged === 0) {
|
||||
message = localize('lines.0', "Generated reply");
|
||||
message = localize('lines.0', "No changes yet");
|
||||
} else if (linesChanged === 1) {
|
||||
message = localize('lines.1', "Generated reply and changed 1 line");
|
||||
message = localize('lines.1', "Changed 1 line");
|
||||
} else {
|
||||
message = localize('lines.N', "Generated reply and changed {0} lines", linesChanged);
|
||||
message = localize('lines.N', "Changed {0} lines", linesChanged);
|
||||
}
|
||||
this._widget.updateStatus(message);
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import { localize } from 'vs/nls';
|
|||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { ZoneWidget } from 'vs/editor/contrib/zoneWidget/browser/zoneWidget';
|
||||
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, CTX_INTERACTIVE_EDITOR_EMPTY, CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION, CTX_INTERACTIVE_EDITOR_VISIBLE, MENU_INTERACTIVE_EDITOR_WIDGET, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE, IInteractiveEditorSlashCommand } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor';
|
||||
import { CTX_INTERACTIVE_EDITOR_FOCUSED, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_FIRST, CTX_INTERACTIVE_EDITOR_INNER_CURSOR_LAST, CTX_INTERACTIVE_EDITOR_EMPTY, CTX_INTERACTIVE_EDITOR_OUTER_CURSOR_POSITION, CTX_INTERACTIVE_EDITOR_VISIBLE, MENU_INTERACTIVE_EDITOR_WIDGET, MENU_INTERACTIVE_EDITOR_WIDGET_STATUS, MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE, CTX_INTERACTIVE_EDITOR_MESSAGE_CROP_STATE, IInteractiveEditorSlashCommand, MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK } from 'vs/workbench/contrib/interactiveEditor/common/interactiveEditor';
|
||||
import { IModelDeltaDecoration, ITextModel } from 'vs/editor/common/model';
|
||||
import { Dimension, addDisposableListener, getTotalHeight, getTotalWidth, h, reset } from 'vs/base/browser/dom';
|
||||
import { Emitter, Event, MicrotaskEmitter } from 'vs/base/common/event';
|
||||
|
@ -137,7 +137,8 @@ export class InteractiveEditorWidget {
|
|||
h('div.previewCreate.hidden@previewCreate'),
|
||||
h('div.status@status', [
|
||||
h('div.actions.hidden@statusToolbar'),
|
||||
h('div.label.hidden@statusLabel')
|
||||
h('div.label.hidden@statusLabel'),
|
||||
h('div.actions.hidden@feedbackToolbar'),
|
||||
]),
|
||||
h('div.markdownMessage.hidden@markdownMessage', [
|
||||
h('div.message@message'),
|
||||
|
@ -293,6 +294,10 @@ export class InteractiveEditorWidget {
|
|||
this._store.add(statusToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
|
||||
this._store.add(statusToolbar);
|
||||
|
||||
const feedbackToolbar = this._instantiationService.createInstance(MenuWorkbenchToolBar, this._elements.feedbackToolbar, MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK, { ...workbenchToolbarOptions, hiddenItemStrategy: HiddenItemStrategy.Ignore });
|
||||
this._store.add(feedbackToolbar.onDidChangeMenuItems(() => this._onDidChangeHeight.fire()));
|
||||
this._store.add(feedbackToolbar);
|
||||
|
||||
// preview editors
|
||||
this._previewDiffEditor = this._store.add(_instantiationService.createInstance(EmbeddedDiffEditorWidget, this._elements.previewDiff, _previewEditorEditorOptions, { modifiedEditor: codeEditorWidgetOptions, originalEditor: codeEditorWidgetOptions }, parentEditor));
|
||||
|
||||
|
@ -389,6 +394,7 @@ export class InteractiveEditorWidget {
|
|||
|
||||
updateToolbar(show: boolean) {
|
||||
this._elements.statusToolbar.classList.toggle('hidden', !show);
|
||||
this._elements.feedbackToolbar.classList.toggle('hidden', !show);
|
||||
this._onDidChangeHeight.fire();
|
||||
}
|
||||
|
||||
|
@ -437,6 +443,7 @@ export class InteractiveEditorWidget {
|
|||
reset(this._elements.statusLabel);
|
||||
this._elements.statusLabel.classList.toggle('hidden', true);
|
||||
this._elements.statusToolbar.classList.add('hidden');
|
||||
this._elements.feedbackToolbar.classList.add('hidden');
|
||||
this.hideCreatePreview();
|
||||
this.hideEditsPreview();
|
||||
this._onDidChangeHeight.fire();
|
||||
|
|
|
@ -123,6 +123,7 @@ export const CTX_INTERACTIVE_EDITOR_EDIT_MODE = new RawContextKey<EditMode>('con
|
|||
export const MENU_INTERACTIVE_EDITOR_WIDGET = MenuId.for('interactiveEditorWidget');
|
||||
export const MENU_INTERACTIVE_EDITOR_WIDGET_MARKDOWN_MESSAGE = MenuId.for('interactiveEditorWidget.markdownMessage');
|
||||
export const MENU_INTERACTIVE_EDITOR_WIDGET_STATUS = MenuId.for('interactiveEditorWidget.status');
|
||||
export const MENU_INTERACTIVE_EDITOR_WIDGET_FEEDBACK = MenuId.for('interactiveEditorWidget.feedback');
|
||||
export const MENU_INTERACTIVE_EDITOR_WIDGET_DISCARD = MenuId.for('interactiveEditorWidget.undo');
|
||||
|
||||
// --- colors
|
||||
|
|
Loading…
Reference in a new issue