mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Merge from vscode 817eb6b0c720a4ecbc13c020afbbebfed667aa09 (#7356)
This commit is contained in:
@@ -19,7 +19,7 @@ import { ICompositeControl } from 'vs/workbench/common/composite';
|
||||
import { ActionRunner, IAction } from 'vs/base/common/actions';
|
||||
import { IFileService } from 'vs/platform/files/common/files';
|
||||
import { IPathData } from 'vs/platform/windows/common/windows';
|
||||
import { coalesce } from 'vs/base/common/arrays';
|
||||
import { coalesce, firstOrDefault } from 'vs/base/common/arrays';
|
||||
|
||||
export const ActiveEditorContext = new RawContextKey<string | null>('activeEditor', null);
|
||||
export const ActiveEditorIsSaveableContext = new RawContextKey<boolean>('activeEditorIsSaveable', false);
|
||||
@@ -384,11 +384,7 @@ export abstract class EditorInput extends Disposable implements IEditorInput {
|
||||
* for the input. This allows subclasses to decide late which editor to use for the input on a case by case basis.
|
||||
*/
|
||||
getPreferredEditorId(candidates: string[]): string | undefined {
|
||||
if (candidates.length > 0) {
|
||||
return candidates[0];
|
||||
}
|
||||
|
||||
return undefined;
|
||||
return firstOrDefault(candidates);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,10 +25,6 @@ export class DataUriEditorInput extends EditorInput {
|
||||
) {
|
||||
super();
|
||||
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.resource = resource;
|
||||
|
||||
if (!this.name || !this.description) {
|
||||
const metadata = DataUri.parseMetaData(this.resource);
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
|
||||
/**
|
||||
* An editor model whith an in-memory, readonly content that is backed by an existing editor model.
|
||||
* An editor model for in-memory, readonly content that is backed by an existing editor model.
|
||||
*/
|
||||
export class ResourceEditorModel extends BaseTextEditorModel {
|
||||
|
||||
@@ -34,4 +34,4 @@ export class ResourceEditorModel extends BaseTextEditorModel {
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
52
src/vs/workbench/common/markdownDocumentRenderer.ts
Normal file
52
src/vs/workbench/common/markdownDocumentRenderer.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as marked from 'vs/base/common/marked/marked';
|
||||
import { tokenizeToString } from 'vs/editor/common/modes/textToHtmlTokenizer';
|
||||
import { ITokenizationSupport, TokenizationRegistry } from 'vs/editor/common/modes';
|
||||
import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
|
||||
/**
|
||||
* Renders a string of markdown as a document.
|
||||
*
|
||||
* Uses VS Code's syntax highlighting code blocks.
|
||||
*/
|
||||
export async function renderMarkdownDocument(
|
||||
text: string,
|
||||
extensionService: IExtensionService,
|
||||
modeService: IModeService,
|
||||
): Promise<string> {
|
||||
const renderer = await getRenderer(text, extensionService, modeService);
|
||||
return marked(text, { renderer });
|
||||
}
|
||||
|
||||
async function getRenderer(
|
||||
text: string,
|
||||
extensionService: IExtensionService,
|
||||
modeService: IModeService,
|
||||
): Promise<marked.Renderer> {
|
||||
let result: Promise<ITokenizationSupport | null>[] = [];
|
||||
const renderer = new marked.Renderer();
|
||||
renderer.code = (_code, lang) => {
|
||||
const modeId = modeService.getModeIdForLanguageName(lang);
|
||||
if (modeId) {
|
||||
result.push(extensionService.whenInstalledExtensionsRegistered().then<ITokenizationSupport | null>(() => {
|
||||
modeService.triggerMode(modeId);
|
||||
return TokenizationRegistry.getPromise(modeId);
|
||||
}));
|
||||
}
|
||||
return '';
|
||||
};
|
||||
|
||||
marked(text, { renderer });
|
||||
await Promise.all(result);
|
||||
|
||||
renderer.code = (code, lang) => {
|
||||
const modeId = modeService.getModeIdForLanguageName(lang);
|
||||
return `<code>${tokenizeToString(code, modeId ? TokenizationRegistry.get(modeId)! : undefined)}</code>`;
|
||||
};
|
||||
return renderer;
|
||||
}
|
||||
@@ -559,6 +559,24 @@ export const NOTIFICATIONS_BORDER = registerColor('notifications.border', {
|
||||
hc: NOTIFICATIONS_CENTER_HEADER_BACKGROUND
|
||||
}, nls.localize('notificationsBorder', "Notifications border color separating from other notifications in the notifications center. Notifications slide in from the bottom right of the window."));
|
||||
|
||||
export const NOTIFICATIONS_ERROR_ICON_FOREGROUND = registerColor('notificationsErrorIcon.foreground', {
|
||||
dark: '#F48771',
|
||||
light: '#A1260D',
|
||||
hc: '#F48771'
|
||||
}, nls.localize('notificationsErrorIconForeground', "The color used for the notification error icon."));
|
||||
|
||||
export const NOTIFICATIONS_WARNING_ICON_FOREGROUND = registerColor('notificationsWarningIcon.foreground', {
|
||||
dark: '#FFCC00',
|
||||
light: '#DDB100',
|
||||
hc: '#FFCC00'
|
||||
}, nls.localize('notificationsWarningIconForeground', "The color used for the notification warning icon."));
|
||||
|
||||
export const NOTIFICATIONS_INFO_ICON_FOREGROUND = registerColor('notificationsInfoIcon.foreground', {
|
||||
dark: '#75BEFF',
|
||||
light: '#007ACC',
|
||||
hc: '#75BEFF'
|
||||
}, nls.localize('notificationsInfoIconForeground', "The color used for the notification info icon."));
|
||||
|
||||
/**
|
||||
* Base class for all themable workbench components.
|
||||
*/
|
||||
|
||||
@@ -130,8 +130,6 @@ export interface IViewDescriptor {
|
||||
|
||||
readonly when?: ContextKeyExpr;
|
||||
|
||||
readonly group?: string;
|
||||
|
||||
readonly order?: number;
|
||||
|
||||
readonly weight?: number;
|
||||
@@ -146,6 +144,11 @@ export interface IViewDescriptor {
|
||||
readonly workspace?: boolean;
|
||||
|
||||
readonly focusCommand?: { id: string, keybindings?: IKeybindings };
|
||||
|
||||
// For contributed remote explorer views
|
||||
readonly group?: string;
|
||||
|
||||
readonly remoteAuthority?: string;
|
||||
}
|
||||
|
||||
export interface IViewDescriptorCollection extends IDisposable {
|
||||
|
||||
Reference in New Issue
Block a user