mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-19 17:58:39 +00:00
This commit is contained in:
@@ -33,6 +33,7 @@ export const Context = {
|
||||
Visible: historyNavigationVisible,
|
||||
HasFocusedSuggestion: new RawContextKey<boolean>('suggestWidgetHasFocusedSuggestion', false, localize('suggestWidgetHasSelection', "Whether any suggestion is focused")),
|
||||
DetailsVisible: new RawContextKey<boolean>('suggestWidgetDetailsVisible', false, localize('suggestWidgetDetailsVisible', "Whether suggestion details are visible")),
|
||||
DetailsFocused: new RawContextKey<boolean>('suggestWidgetDetailsFocused', false, localize('suggestWidgetDetailsFocused', "Whether the details pane of the suggest widget has focus")),
|
||||
MultipleSuggestions: new RawContextKey<boolean>('suggestWidgetMultipleSuggestions', false, localize('suggestWidgetMultipleSuggestions', "Whether there are multiple suggestions to pick from")),
|
||||
MakesTextEdit: new RawContextKey<boolean>('suggestionMakesTextEdit', true, localize('suggestionMakesTextEdit', "Whether inserting the current suggestion yields in a change or has everything already been typed")),
|
||||
AcceptSuggestionsOnEnter: new RawContextKey<boolean>('acceptSuggestionOnEnter', true, localize('acceptSuggestionOnEnter', "Whether suggestions are inserted when pressing Enter")),
|
||||
|
||||
@@ -9,9 +9,7 @@ import { CancellationTokenSource } from '../../../../base/common/cancellation.js
|
||||
import { onUnexpectedError, onUnexpectedExternalError } from '../../../../base/common/errors.js';
|
||||
import { Emitter, Event } from '../../../../base/common/event.js';
|
||||
import { KeyCode, KeyMod } from '../../../../base/common/keyCodes.js';
|
||||
import { KeyCodeChord } from '../../../../base/common/keybindings.js';
|
||||
import { DisposableStore, dispose, IDisposable, MutableDisposable, toDisposable } from '../../../../base/common/lifecycle.js';
|
||||
import * as platform from '../../../../base/common/platform.js';
|
||||
import { StopWatch } from '../../../../base/common/stopwatch.js';
|
||||
import { assertType, isObject } from '../../../../base/common/types.js';
|
||||
import { StableEditorScrollState } from '../../../browser/stableEditorScroll.js';
|
||||
@@ -214,21 +212,6 @@ export class SuggestController implements IEditorContribution {
|
||||
ctxCanResolve.set(Boolean(item.provider.resolveCompletionItem) || Boolean(item.completion.documentation) || item.completion.detail !== item.completion.label);
|
||||
}));
|
||||
|
||||
this._toDispose.add(widget.onDetailsKeyDown(e => {
|
||||
// cmd + c on macOS, ctrl + c on Win / Linux
|
||||
if (
|
||||
e.toKeyCodeChord().equals(new KeyCodeChord(true, false, false, false, KeyCode.KeyC)) ||
|
||||
(platform.isMacintosh && e.toKeyCodeChord().equals(new KeyCodeChord(false, false, false, true, KeyCode.KeyC)))
|
||||
) {
|
||||
e.stopPropagation();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!e.toKeyCodeChord().isModifierKey()) {
|
||||
this.editor.focus();
|
||||
}
|
||||
}));
|
||||
|
||||
if (this._wantsForceRenderingAbove) {
|
||||
widget.forceRenderingAbove();
|
||||
}
|
||||
@@ -1126,6 +1109,24 @@ registerEditorCommand(new SuggestCommand({
|
||||
}));
|
||||
|
||||
|
||||
registerEditorCommand(new class extends EditorCommand {
|
||||
constructor() {
|
||||
super({
|
||||
id: 'suggestWidgetCopy',
|
||||
precondition: SuggestContext.DetailsFocused,
|
||||
kbOpts: {
|
||||
weight: weight + 10,
|
||||
kbExpr: SuggestContext.DetailsFocused,
|
||||
primary: KeyMod.CtrlCmd | KeyCode.KeyC,
|
||||
win: { primary: KeyMod.CtrlCmd | KeyCode.KeyC, secondary: [KeyMod.CtrlCmd | KeyCode.Insert] }
|
||||
}
|
||||
});
|
||||
}
|
||||
runEditorCommand(_accessor: ServicesAccessor, editor: ICodeEditor) {
|
||||
getWindow(editor.getDomNode()).document.execCommand('copy');
|
||||
}
|
||||
}());
|
||||
|
||||
registerEditorAction(class extends EditorAction {
|
||||
|
||||
constructor() {
|
||||
|
||||
@@ -130,6 +130,7 @@ export class SuggestWidget implements IDisposable {
|
||||
private readonly _ctxSuggestWidgetDetailsVisible: IContextKey<boolean>;
|
||||
private readonly _ctxSuggestWidgetMultipleSuggestions: IContextKey<boolean>;
|
||||
private readonly _ctxSuggestWidgetHasFocusedSuggestion: IContextKey<boolean>;
|
||||
private readonly _ctxSuggestWidgetDetailsFocused: IContextKey<boolean>;
|
||||
|
||||
private readonly _showTimeout = new TimeoutTimer();
|
||||
private readonly _disposables = new DisposableStore();
|
||||
@@ -292,6 +293,12 @@ export class SuggestWidget implements IDisposable {
|
||||
this._ctxSuggestWidgetDetailsVisible = SuggestContext.DetailsVisible.bindTo(_contextKeyService);
|
||||
this._ctxSuggestWidgetMultipleSuggestions = SuggestContext.MultipleSuggestions.bindTo(_contextKeyService);
|
||||
this._ctxSuggestWidgetHasFocusedSuggestion = SuggestContext.HasFocusedSuggestion.bindTo(_contextKeyService);
|
||||
this._ctxSuggestWidgetDetailsFocused = SuggestContext.DetailsFocused.bindTo(_contextKeyService);
|
||||
|
||||
const detailsFocusTracker = dom.trackFocus(this._details.widget.domNode);
|
||||
this._disposables.add(detailsFocusTracker);
|
||||
this._disposables.add(detailsFocusTracker.onDidFocus(() => this._ctxSuggestWidgetDetailsFocused.set(true)));
|
||||
this._disposables.add(detailsFocusTracker.onDidBlur(() => this._ctxSuggestWidgetDetailsFocused.set(false)));
|
||||
|
||||
this._disposables.add(dom.addStandardDisposableListener(this._details.widget.domNode, 'keydown', e => {
|
||||
this._onDetailsKeydown.fire(e);
|
||||
|
||||
Reference in New Issue
Block a user