mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode cfbd1999769f4f08dce29629fb92fdc0fac53829
This commit is contained in:
@@ -337,6 +337,44 @@ export abstract class EditorAction extends EditorCommand {
|
||||
public abstract run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void | Promise<void>;
|
||||
}
|
||||
|
||||
export abstract class MultiEditorAction extends EditorAction {
|
||||
private readonly _implementations: [number, CommandImplementation][] = [];
|
||||
|
||||
constructor(opts: IActionOptions) {
|
||||
super(opts);
|
||||
}
|
||||
|
||||
public addImplementation(priority: number, implementation: CommandImplementation): IDisposable {
|
||||
this._implementations.push([priority, implementation]);
|
||||
this._implementations.sort((a, b) => b[0] - a[0]);
|
||||
return {
|
||||
dispose: () => {
|
||||
for (let i = 0; i < this._implementations.length; i++) {
|
||||
if (this._implementations[i][1] === implementation) {
|
||||
this._implementations.splice(i, 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void | Promise<void> {
|
||||
this.reportTelemetry(accessor, editor);
|
||||
|
||||
for (const impl of this._implementations) {
|
||||
if (impl[1](accessor, args)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
return this.run(accessor, editor, args || {});
|
||||
}
|
||||
|
||||
public abstract run(accessor: ServicesAccessor, editor: ICodeEditor, args: any): void | Promise<void>;
|
||||
|
||||
}
|
||||
|
||||
//#endregion EditorAction
|
||||
|
||||
//#region EditorAction2
|
||||
@@ -474,6 +512,11 @@ export function registerEditorAction<T extends EditorAction>(ctor: { new(): T; }
|
||||
return action;
|
||||
}
|
||||
|
||||
export function registerMultiEditorAction<T extends MultiEditorAction>(action: T): T {
|
||||
EditorContributionRegistry.INSTANCE.registerEditorAction(action);
|
||||
return action;
|
||||
}
|
||||
|
||||
export function registerInstantiatedEditorAction(editorAction: EditorAction): void {
|
||||
EditorContributionRegistry.INSTANCE.registerEditorAction(editorAction);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ export const PLAINTEXT_LANGUAGE_IDENTIFIER = new LanguageIdentifier(PLAINTEXT_MO
|
||||
|
||||
ModesRegistry.registerLanguage({
|
||||
id: PLAINTEXT_MODE_ID,
|
||||
extensions: ['.txt', '.gitignore'],
|
||||
extensions: ['.txt'],
|
||||
aliases: [nls.localize('plainText.alias', "Plain Text"), 'text'],
|
||||
mimetypes: ['text/plain']
|
||||
});
|
||||
|
||||
@@ -49,7 +49,14 @@ export class ContextMenuController implements IEditorContribution {
|
||||
this._toDispose.add(this._editor.onContextMenu((e: IEditorMouseEvent) => this._onContextMenu(e)));
|
||||
this._toDispose.add(this._editor.onMouseWheel((e: IMouseWheelEvent) => {
|
||||
if (this._contextMenuIsBeingShownCount > 0) {
|
||||
this._contextViewService.hideContextView();
|
||||
const view = this._contextViewService.getContextViewElement();
|
||||
const target = e.srcElement as HTMLElement;
|
||||
|
||||
// Event triggers on shadow root host first
|
||||
// Check if the context view is under this host before hiding it #103169
|
||||
if (!(target.shadowRoot && dom.getShadowRoot(view) === target.shadowRoot)) {
|
||||
this._contextViewService.hideContextView();
|
||||
}
|
||||
}
|
||||
}));
|
||||
this._toDispose.add(this._editor.onKeyDown((e: IKeyboardEvent) => {
|
||||
|
||||
@@ -9,7 +9,7 @@ import { KeyCode, KeyMod } from 'vs/base/common/keyCodes';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import * as strings from 'vs/base/common/strings';
|
||||
import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { EditorAction, EditorCommand, ServicesAccessor, registerEditorAction, registerEditorCommand, registerEditorContribution } from 'vs/editor/browser/editorExtensions';
|
||||
import { EditorAction, EditorCommand, ServicesAccessor, registerEditorAction, registerEditorCommand, registerEditorContribution, MultiEditorAction, registerMultiEditorAction } from 'vs/editor/browser/editorExtensions';
|
||||
import { IEditorContribution } from 'vs/editor/common/editorCommon';
|
||||
import { EditorContextKeys } from 'vs/editor/common/editorContextKeys';
|
||||
import { CONTEXT_FIND_INPUT_FOCUSED, CONTEXT_FIND_WIDGET_VISIBLE, FIND_IDS, FindModelBoundToEditorModel, ToggleCaseSensitiveKeybinding, ToggleRegexKeybinding, ToggleSearchScopeKeybinding, ToggleWholeWordKeybinding, CONTEXT_REPLACE_INPUT_FOCUSED } from 'vs/editor/contrib/find/findModel';
|
||||
@@ -457,7 +457,7 @@ export class FindController extends CommonFindController implements IFindControl
|
||||
}
|
||||
}
|
||||
|
||||
export class StartFindAction extends EditorAction {
|
||||
export class StartFindAction extends MultiEditorAction {
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
@@ -706,7 +706,7 @@ export class PreviousSelectionMatchFindAction extends SelectionMatchFindAction {
|
||||
}
|
||||
}
|
||||
|
||||
export class StartFindReplaceAction extends EditorAction {
|
||||
export class StartFindReplaceAction extends MultiEditorAction {
|
||||
|
||||
constructor() {
|
||||
super({
|
||||
@@ -769,7 +769,8 @@ export class StartFindReplaceAction extends EditorAction {
|
||||
|
||||
registerEditorContribution(CommonFindController.ID, FindController);
|
||||
|
||||
registerEditorAction(StartFindAction);
|
||||
export const EditorStartFindAction = new StartFindAction();
|
||||
registerMultiEditorAction(EditorStartFindAction);
|
||||
registerEditorAction(StartFindWithSelectionAction);
|
||||
registerEditorAction(NextMatchFindAction);
|
||||
registerEditorAction(NextMatchFindAction2);
|
||||
@@ -777,7 +778,8 @@ registerEditorAction(PreviousMatchFindAction);
|
||||
registerEditorAction(PreviousMatchFindAction2);
|
||||
registerEditorAction(NextSelectionMatchFindAction);
|
||||
registerEditorAction(PreviousSelectionMatchFindAction);
|
||||
registerEditorAction(StartFindReplaceAction);
|
||||
export const EditorStartFindReplaceAction = new StartFindReplaceAction();
|
||||
registerMultiEditorAction(EditorStartFindReplaceAction);
|
||||
|
||||
const FindCommand = EditorCommand.bindToContribution<CommonFindController>(CommonFindController.get);
|
||||
|
||||
|
||||
@@ -216,6 +216,15 @@ export abstract class ReferencesController implements IEditorContribution {
|
||||
}
|
||||
}
|
||||
|
||||
async revealReference(reference: OneReference): Promise<void> {
|
||||
if (!this._editor.hasModel() || !this._model || !this._widget) {
|
||||
// can be called while still resolving...
|
||||
return;
|
||||
}
|
||||
|
||||
await this._widget.revealReference(reference);
|
||||
}
|
||||
|
||||
closeWidget(focusEditor = true): void {
|
||||
dispose(this._widget);
|
||||
dispose(this._model);
|
||||
@@ -365,6 +374,24 @@ KeybindingsRegistry.registerKeybindingRule({
|
||||
});
|
||||
|
||||
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'revealReference',
|
||||
weight: KeybindingWeight.WorkbenchContrib,
|
||||
primary: KeyCode.Enter,
|
||||
mac: {
|
||||
primary: KeyCode.Enter,
|
||||
secondary: [KeyMod.CtrlCmd | KeyCode.DownArrow]
|
||||
},
|
||||
when: ContextKeyExpr.and(ctxReferenceSearchVisible, WorkbenchListFocusContextKey),
|
||||
handler(accessor: ServicesAccessor) {
|
||||
const listService = accessor.get(IListService);
|
||||
const focus = <any[]>listService.lastFocusedList?.getFocus();
|
||||
if (Array.isArray(focus) && focus[0] instanceof OneReference) {
|
||||
withController(accessor, controller => controller.revealReference(focus[0]));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
KeybindingsRegistry.registerCommandAndKeybindingRule({
|
||||
id: 'openReferenceToSide',
|
||||
weight: KeybindingWeight.EditorContrib,
|
||||
|
||||
@@ -481,6 +481,11 @@ export class ReferenceWidget extends peekView.PeekViewWidget {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async revealReference(reference: OneReference): Promise<void> {
|
||||
await this._revealReference(reference, false);
|
||||
this._onDidSelectReference.fire({ element: reference, kind: 'goto', source: 'tree' });
|
||||
}
|
||||
|
||||
private _revealedReference?: OneReference;
|
||||
|
||||
private async _revealReference(reference: OneReference, revealParent: boolean): Promise<void> {
|
||||
|
||||
@@ -618,7 +618,7 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<Compl
|
||||
detail || '',
|
||||
documentation ? (typeof documentation === 'string' ? documentation : documentation.value) : '');
|
||||
|
||||
return nls.localize('ariaCurrenttSuggestionReadDetails', "Item {0}, docs: {1}", textLabel, docs);
|
||||
return nls.localize('ariaCurrenttSuggestionReadDetails', "{0}, docs: {1}", textLabel, docs);
|
||||
} else {
|
||||
return textLabel;
|
||||
}
|
||||
|
||||
@@ -7,30 +7,30 @@ import { ITextBufferBuilder } from 'vs/editor/common/model';
|
||||
import { BenchmarkSuite } from 'vs/editor/test/common/model/benchmark/benchmarkUtils';
|
||||
import { generateRandomChunkWithLF, generateRandomReplaces } from 'vs/editor/test/common/model/linesTextBuffer/textBufferAutoTestUtils';
|
||||
|
||||
let fileSizes = [1, 1000, 64 * 1000, 32 * 1000 * 1000];
|
||||
const fileSizes = [1, 1000, 64 * 1000, 32 * 1000 * 1000];
|
||||
|
||||
for (let fileSize of fileSizes) {
|
||||
let chunks: string[] = [];
|
||||
for (const fileSize of fileSizes) {
|
||||
const chunks: string[] = [];
|
||||
|
||||
let chunkCnt = Math.floor(fileSize / (64 * 1000));
|
||||
const chunkCnt = Math.floor(fileSize / (64 * 1000));
|
||||
if (chunkCnt === 0) {
|
||||
chunks.push(generateRandomChunkWithLF(fileSize, fileSize));
|
||||
} else {
|
||||
let chunk = generateRandomChunkWithLF(64 * 1000, 64 * 1000);
|
||||
const chunk = generateRandomChunkWithLF(64 * 1000, 64 * 1000);
|
||||
// try to avoid OOM
|
||||
for (let j = 0; j < chunkCnt; j++) {
|
||||
chunks.push(Buffer.from(chunk + j).toString());
|
||||
}
|
||||
}
|
||||
|
||||
let replaceSuite = new BenchmarkSuite({
|
||||
const replaceSuite = new BenchmarkSuite({
|
||||
name: `File Size: ${fileSize}Byte`,
|
||||
iterations: 10
|
||||
});
|
||||
|
||||
let edits = generateRandomReplaces(chunks, 500, 5, 10);
|
||||
const edits = generateRandomReplaces(chunks, 500, 5, 10);
|
||||
|
||||
for (let i of [10, 100, 500]) {
|
||||
for (const i of [10, 100, 500]) {
|
||||
replaceSuite.add({
|
||||
name: `replace ${i} occurrences`,
|
||||
buildBuffer: (textBufferBuilder: ITextBufferBuilder) => {
|
||||
|
||||
Reference in New Issue
Block a user