mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-01 17:23:35 -05:00
Initial VS Code 1.19 source merge (#571)
* Initial 1.19 xcopy * Fix yarn build * Fix numerous build breaks * Next batch of build break fixes * More build break fixes * Runtime breaks * Additional post merge fixes * Fix windows setup file * Fix test failures. * Update license header blocks to refer to source eula
This commit is contained in:
79
src/vs/editor/browser/services/codeEditorService.ts
Normal file
79
src/vs/editor/browser/services/codeEditorService.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import Event from 'vs/base/common/event';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IDecorationRenderOptions, IModelDecorationOptions, IModel } from 'vs/editor/common/editorCommon';
|
||||
import { IEditor } from 'vs/platform/editor/common/editor';
|
||||
import { ICodeEditor, IDiffEditor, isCodeEditor, isDiffEditor } from 'vs/editor/browser/editorBrowser';
|
||||
|
||||
export const ICodeEditorService = createDecorator<ICodeEditorService>('codeEditorService');
|
||||
|
||||
export interface ICodeEditorService {
|
||||
_serviceBrand: any;
|
||||
|
||||
onCodeEditorAdd: Event<ICodeEditor>;
|
||||
onCodeEditorRemove: Event<ICodeEditor>;
|
||||
|
||||
onDiffEditorAdd: Event<IDiffEditor>;
|
||||
onDiffEditorRemove: Event<IDiffEditor>;
|
||||
|
||||
addCodeEditor(editor: ICodeEditor): void;
|
||||
removeCodeEditor(editor: ICodeEditor): void;
|
||||
listCodeEditors(): ICodeEditor[];
|
||||
|
||||
addDiffEditor(editor: IDiffEditor): void;
|
||||
removeDiffEditor(editor: IDiffEditor): void;
|
||||
listDiffEditors(): IDiffEditor[];
|
||||
|
||||
/**
|
||||
* Returns the current focused code editor (if the focus is in the editor or in an editor widget) or null.
|
||||
*/
|
||||
getFocusedCodeEditor(): ICodeEditor;
|
||||
|
||||
registerDecorationType(key: string, options: IDecorationRenderOptions, parentTypeKey?: string): void;
|
||||
removeDecorationType(key: string): void;
|
||||
resolveDecorationOptions(typeKey: string, writable: boolean): IModelDecorationOptions;
|
||||
|
||||
setTransientModelProperty(model: IModel, key: string, value: any): void;
|
||||
getTransientModelProperty(model: IModel, key: string): any;
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses `editor.getControl()` and returns either a `codeEditor` or a `diffEditor` or nothing.
|
||||
*/
|
||||
export function getCodeOrDiffEditor(editor: IEditor): { codeEditor: ICodeEditor; diffEditor: IDiffEditor } {
|
||||
if (editor) {
|
||||
let control = editor.getControl();
|
||||
if (control) {
|
||||
if (isCodeEditor(control)) {
|
||||
return {
|
||||
codeEditor: control,
|
||||
diffEditor: null
|
||||
};
|
||||
}
|
||||
if (isDiffEditor(control)) {
|
||||
return {
|
||||
codeEditor: null,
|
||||
diffEditor: control
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
codeEditor: null,
|
||||
diffEditor: null
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses `editor.getControl()` and returns either the code editor, or the modified editor of a diff editor or nothing.
|
||||
*/
|
||||
export function getCodeEditor(editor: IEditor): ICodeEditor {
|
||||
let r = getCodeOrDiffEditor(editor);
|
||||
return r.codeEditor || (r.diffEditor && <ICodeEditor>r.diffEditor.getModifiedEditor()) || null;
|
||||
}
|
||||
Reference in New Issue
Block a user