mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from vscode 6e530127a1bb8ffbd1bfb77dc680c321dc0d71f5 (#6844)
This commit is contained in:
@@ -84,7 +84,7 @@ export class CmsUtils {
|
||||
// CMS APIs
|
||||
public async getCmsService(): Promise<mssql.ICmsService> {
|
||||
if (!this._cmsService) {
|
||||
this._cmsService = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.mssql).cmsService;
|
||||
this._cmsService = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.IExtension).cmsService;
|
||||
}
|
||||
return this._cmsService;
|
||||
}
|
||||
|
||||
@@ -371,7 +371,7 @@ export class DataTierApplicationWizard {
|
||||
}
|
||||
|
||||
private static async getService(providerName: string): Promise<mssql.IDacFxService> {
|
||||
const service = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.mssql).dacFx;
|
||||
const service = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.IExtension).dacFx;
|
||||
return service;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ if (context.RunTest) {
|
||||
setup(async function () {
|
||||
// Set up CMS provider
|
||||
if (!cmsService) {
|
||||
cmsService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.mssql)).cmsService;
|
||||
cmsService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.IExtension)).cmsService;
|
||||
assert(cmsService !== undefined);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ if (context.RunTest) {
|
||||
const databaseName = 'ADS_deployDacpac_' + now.getTime().toString();
|
||||
|
||||
try {
|
||||
const dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.mssql)).dacFx;
|
||||
const dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.IExtension)).dacFx;
|
||||
assert(dacfxService, 'DacFx Service Provider is not available');
|
||||
|
||||
// Deploy dacpac
|
||||
@@ -72,7 +72,7 @@ if (context.RunTest) {
|
||||
const databaseName = 'ADS_importBacpac_' + now.getTime().toString();
|
||||
|
||||
try {
|
||||
let dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.mssql)).dacFx;
|
||||
let dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.IExtension)).dacFx;
|
||||
assert(dacfxService, 'DacFx Service Provider is not available');
|
||||
|
||||
// Import bacpac
|
||||
|
||||
@@ -31,7 +31,7 @@ if (context.RunTest) {
|
||||
suiteSetup(async function () {
|
||||
let attempts: number = 20;
|
||||
while (attempts > 0) {
|
||||
schemaCompareService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.mssql)).schemaCompare;
|
||||
schemaCompareService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.IExtension)).schemaCompare;
|
||||
if (schemaCompareService) {
|
||||
break;
|
||||
}
|
||||
@@ -120,7 +120,7 @@ class SchemaCompareTester {
|
||||
const targetDB: string = 'ads_schemaCompare_targetDB_' + now.getTime().toString();
|
||||
|
||||
try {
|
||||
let dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.mssql)).dacFx;
|
||||
let dacfxService = ((await vscode.extensions.getExtension(mssql.extension.name).activate() as mssql.IExtension)).dacFx;
|
||||
assert(dacfxService, 'DacFx Service Provider is not available');
|
||||
let result1 = await dacfxService.deployDacpac(dacpac1, sourceDB, true, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
let result2 = await dacfxService.deployDacpac(dacpac2, targetDB, true, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
@@ -200,7 +200,7 @@ class SchemaCompareTester {
|
||||
const targetDB: string = 'ads_schemaCompare_targetDB_' + now.getTime().toString();
|
||||
|
||||
try {
|
||||
let dacfxService = (vscode.extensions.getExtension('mssql').exports as mssql.mssql).dacFx;
|
||||
let dacfxService = (vscode.extensions.getExtension('mssql').exports as mssql.IExtension).dacFx;
|
||||
assert(dacfxService, 'DacFx Service Provider is not available');
|
||||
let result = await dacfxService.deployDacpac(path.join(__dirname, 'testData/Database2.dacpac'), targetDB, true, ownerUri, azdata.TaskExecutionMode.execute);
|
||||
|
||||
@@ -258,7 +258,7 @@ class SchemaCompareTester {
|
||||
assert(schemaCompareResult.errorMessage === null, `Expected: there should be no error. Actual Error message: "${schemaCompareResult.errorMessage}"`);
|
||||
assert(schemaCompareResult.success === true, `Expected: success in schema compare, Actual: Failure`);
|
||||
assert(schemaCompareResult.differences.length === 4, `Expected: 4 differences. Actual differences: "${schemaCompareResult.differences.length}"`);
|
||||
assert(schemaCompareResult.operationId === operationId, `Operation Id Expected to be same as passed. Expected : ${operationId}, Actual ${schemaCompareResult.operationId}`)
|
||||
assert(schemaCompareResult.operationId === operationId, `Operation Id Expected to be same as passed. Expected : ${operationId}, Actual ${schemaCompareResult.operationId}`);
|
||||
}
|
||||
|
||||
private async assertScriptGenerationResult(resultstatus: azdata.ResultStatus, server: string, database: string): Promise<void> {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
|
||||
"Once accepted there, we are happy to receive an update request."
|
||||
],
|
||||
"version": "https://github.com/microsoft/vscode-markdown-tm-grammar/commit/05ccfa3db6edbd357390431f9e316adb38ba41d8",
|
||||
"version": "https://github.com/microsoft/vscode-markdown-tm-grammar/commit/eb3898715b50d7911377a650e383a768a3a21f25",
|
||||
"name": "Markdown",
|
||||
"scopeName": "text.html.markdown",
|
||||
"patterns": [
|
||||
@@ -1855,12 +1855,12 @@
|
||||
"name": "markup.fenced_code.block.markdown"
|
||||
},
|
||||
"heading": {
|
||||
"match": "(?:^|\\G)[ ]{0,3}((#{1,6})\\s*(?=[\\S[^#]]).*?\\s*(#{1,6})?)$\\n?",
|
||||
"match": "(?:^|\\G)[ ]{0,3}((#{1,6})\\s+(?=[\\S[^#]]).*?\\s*(#{1,6})?)$\\n?",
|
||||
"captures": {
|
||||
"1": {
|
||||
"patterns": [
|
||||
{
|
||||
"match": "(#{6})\\s*(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"match": "(#{6})\\s+(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"name": "heading.6.markdown",
|
||||
"captures": {
|
||||
"1": {
|
||||
@@ -1875,7 +1875,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(#{5})\\s*(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"match": "(#{5})\\s+(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"name": "heading.5.markdown",
|
||||
"captures": {
|
||||
"1": {
|
||||
@@ -1890,7 +1890,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(#{4})\\s*(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"match": "(#{4})\\s+(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"name": "heading.4.markdown",
|
||||
"captures": {
|
||||
"1": {
|
||||
@@ -1905,7 +1905,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(#{3})\\s*(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"match": "(#{3})\\s+(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"name": "heading.3.markdown",
|
||||
"captures": {
|
||||
"1": {
|
||||
@@ -1920,7 +1920,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(#{2})\\s*(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"match": "(#{2})\\s+(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"name": "heading.2.markdown",
|
||||
"captures": {
|
||||
"1": {
|
||||
@@ -1935,7 +1935,7 @@
|
||||
}
|
||||
},
|
||||
{
|
||||
"match": "(#{1})\\s*(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"match": "(#{1})\\s+(?=[\\S[^#]])(.*?)\\s*(\\s+#+)?$\\n?",
|
||||
"name": "heading.1.markdown",
|
||||
"captures": {
|
||||
"1": {
|
||||
@@ -1993,7 +1993,7 @@
|
||||
"1": {
|
||||
"patterns": [
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2015,7 +2015,7 @@
|
||||
"begin": "(\\s*|$)",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
}
|
||||
],
|
||||
"while": "(?i)^(?!.*</(script|style|pre)>)"
|
||||
@@ -2023,10 +2023,10 @@
|
||||
]
|
||||
},
|
||||
{
|
||||
"begin": "(?i)(^|\\G)\\s*(?=</?(address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h1|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul)(\\s|$|/?>))",
|
||||
"begin": "(?i)(^|\\G)\\s*(?=</?[a-zA-Z]+[^\\s/>]*(\\s|$|/?>))",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
}
|
||||
],
|
||||
"while": "^(?!\\s*$)"
|
||||
@@ -2035,7 +2035,7 @@
|
||||
"begin": "(^|\\G)\\s*(?=(<[a-zA-Z0-9\\-](/?>|\\s.*?>)|</[a-zA-Z0-9\\-]>)\\s*$)",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
}
|
||||
],
|
||||
"while": "^(?!\\s*$)"
|
||||
@@ -2095,7 +2095,7 @@
|
||||
"include": "#inline"
|
||||
},
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
},
|
||||
{
|
||||
"include": "#heading-setext"
|
||||
@@ -2152,7 +2152,7 @@
|
||||
"include": "#inline"
|
||||
},
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
},
|
||||
{
|
||||
"include": "#heading-setext"
|
||||
@@ -2246,7 +2246,7 @@
|
||||
"end": "(?<=>)",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -2391,7 +2391,7 @@
|
||||
"end": "(?<=>)",
|
||||
"patterns": [
|
||||
{
|
||||
"include": "text.html.basic"
|
||||
"include": "text.html.derivative"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -24,8 +24,9 @@
|
||||
"onCommand:markdown.showLockedPreviewToSide",
|
||||
"onCommand:markdown.showSource",
|
||||
"onCommand:markdown.showPreviewSecuritySelector",
|
||||
"onWebviewPanel:markdown.preview",
|
||||
"onCommand:notebook.showPreview"
|
||||
"onCommand:markdown.api.render",
|
||||
"onCommand:notebook.showPreview",
|
||||
"onWebviewPanel:markdown.preview"
|
||||
],
|
||||
"contributes": {
|
||||
"commands": [
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
import { ActiveLineMarker } from './activeLineMarker';
|
||||
import { onceDocumentLoaded } from './events';
|
||||
import { createPosterForVsCode } from './messaging';
|
||||
import { getEditorLineNumberForPageOffset, scrollToRevealSourceLine } from './scroll-sync';
|
||||
import { getEditorLineNumberForPageOffset, scrollToRevealSourceLine, getLineElementForFragment } from './scroll-sync';
|
||||
import { getSettings, getData } from './settings';
|
||||
import throttle = require('lodash.throttle');
|
||||
|
||||
@@ -19,7 +19,7 @@ const settings = getSettings();
|
||||
const vscode = acquireVsCodeApi();
|
||||
|
||||
// Set VS Code state
|
||||
let state = getData<{ line: number }>('data-state');
|
||||
let state = getData<{ line: number, fragment: string }>('data-state');
|
||||
vscode.setState(state);
|
||||
|
||||
const messaging = createPosterForVsCode(vscode);
|
||||
@@ -34,10 +34,19 @@ window.onload = () => {
|
||||
onceDocumentLoaded(() => {
|
||||
if (settings.scrollPreviewWithEditor) {
|
||||
setTimeout(() => {
|
||||
const initialLine = +settings.line;
|
||||
if (!isNaN(initialLine)) {
|
||||
scrollDisabled = true;
|
||||
scrollToRevealSourceLine(initialLine);
|
||||
// Try to scroll to fragment if available
|
||||
if (state.fragment) {
|
||||
const element = getLineElementForFragment(state.fragment);
|
||||
if (element) {
|
||||
scrollDisabled = true;
|
||||
scrollToRevealSourceLine(element.line);
|
||||
}
|
||||
} else {
|
||||
const initialLine = +settings.line;
|
||||
if (!isNaN(initialLine)) {
|
||||
scrollDisabled = true;
|
||||
scrollToRevealSourceLine(initialLine);
|
||||
}
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
@@ -161,4 +170,4 @@ if (settings.scrollEditorWithPreview) {
|
||||
|
||||
function escapeRegExp(text: string) {
|
||||
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,3 +134,12 @@ export function getEditorLineNumberForPageOffset(offset: number) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to find the html element by using a fragment id
|
||||
*/
|
||||
export function getLineElementForFragment(fragment: string): CodeLineElement | undefined {
|
||||
return getCodeLineElements().find((element) => {
|
||||
return element.element.id === fragment;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@ export { RefreshPreviewCommand } from './refreshPreview';
|
||||
export { ShowPreviewSecuritySelectorCommand } from './showPreviewSecuritySelector';
|
||||
export { MoveCursorToPositionCommand } from './moveCursorToPosition';
|
||||
export { ToggleLockCommand } from './toggleLock';
|
||||
// {{SQL CARBON EDIT}}
|
||||
export { ShowNotebookPreview } from './showNotebookPreview';
|
||||
export { ShowNotebookPreview } from './showNotebookPreview'; // {{SQL CARBON EDIT}}
|
||||
export { RenderDocument } from './renderDocument';
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { Command } from '../commandManager';
|
||||
import { MarkdownEngine } from '../markdownEngine';
|
||||
import { SkinnyTextDocument } from '../tableOfContentsProvider';
|
||||
|
||||
export class RenderDocument implements Command {
|
||||
public readonly id = 'markdown.api.render';
|
||||
|
||||
public constructor(
|
||||
private readonly engine: MarkdownEngine
|
||||
) { }
|
||||
|
||||
public async execute(document: SkinnyTextDocument | string): Promise<string> {
|
||||
return this.engine.render(document);
|
||||
}
|
||||
}
|
||||
@@ -83,7 +83,7 @@ function registerMarkdownCommands(
|
||||
commandManager.register(new commands.ShowPreviewSecuritySelectorCommand(previewSecuritySelector, previewManager));
|
||||
commandManager.register(new commands.OpenDocumentLinkCommand(engine));
|
||||
commandManager.register(new commands.ToggleLockCommand(previewManager));
|
||||
// {{SQL CARBON EDIT}}
|
||||
commandManager.register(new commands.ShowNotebookPreview(engine));
|
||||
commandManager.register(new commands.ShowNotebookPreview(engine)); // {{SQL CARBON EDIT}}
|
||||
commandManager.register(new commands.RenderDocument(engine));
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
@@ -89,6 +89,7 @@ export class MarkdownPreview extends Disposable {
|
||||
private isScrolling = false;
|
||||
private _disposed: boolean = false;
|
||||
private imageInfo: { id: string, width: number, height: number }[] = [];
|
||||
private scrollToFragment: string | undefined;
|
||||
|
||||
public static async revive(
|
||||
webview: vscode.WebviewPanel,
|
||||
@@ -171,19 +172,19 @@ export class MarkdownPreview extends Disposable {
|
||||
this._locked = locked;
|
||||
this.editor = webview;
|
||||
|
||||
this.editor.onDidDispose(() => {
|
||||
this._register(this.editor.onDidDispose(() => {
|
||||
this.dispose();
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
|
||||
this.editor.onDidChangeViewState(e => {
|
||||
this._register(this.editor.onDidChangeViewState(e => {
|
||||
this._onDidChangeViewStateEmitter.fire(e);
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
|
||||
_contributionProvider.onContributionsChanged(() => {
|
||||
this._register(_contributionProvider.onContributionsChanged(() => {
|
||||
setImmediate(() => this.refresh());
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
|
||||
this.editor.webview.onDidReceiveMessage((e: CacheImageSizesMessage | RevealLineMessage | DidClickMessage | ClickLinkMessage | ShowPreviewSecuritySelectorMessage | PreviewStyleLoadErrorMessage) => {
|
||||
this._register(this.editor.webview.onDidReceiveMessage((e: CacheImageSizesMessage | RevealLineMessage | DidClickMessage | ClickLinkMessage | ShowPreviewSecuritySelectorMessage | PreviewStyleLoadErrorMessage) => {
|
||||
if (e.source !== this._resource.toString()) {
|
||||
return;
|
||||
}
|
||||
@@ -213,21 +214,21 @@ export class MarkdownPreview extends Disposable {
|
||||
vscode.window.showWarningMessage(localize('onPreviewStyleLoadError', "Could not load 'markdown.styles': {0}", e.body.unloadedStyles.join(', ')));
|
||||
break;
|
||||
}
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
|
||||
vscode.workspace.onDidChangeTextDocument(event => {
|
||||
this._register(vscode.workspace.onDidChangeTextDocument(event => {
|
||||
if (this.isPreviewOf(event.document.uri)) {
|
||||
this.refresh();
|
||||
}
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
|
||||
topmostLineMonitor.onDidChangeTopmostLine(event => {
|
||||
this._register(topmostLineMonitor.onDidChangeTopmostLine(event => {
|
||||
if (this.isPreviewOf(event.resource)) {
|
||||
this.updateForView(event.resource, event.line);
|
||||
}
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
|
||||
vscode.window.onDidChangeTextEditorSelection(event => {
|
||||
this._register(vscode.window.onDidChangeTextEditorSelection(event => {
|
||||
if (this.isPreviewOf(event.textEditor.document.uri)) {
|
||||
this.postMessage({
|
||||
type: 'onDidChangeTextEditorSelection',
|
||||
@@ -235,19 +236,19 @@ export class MarkdownPreview extends Disposable {
|
||||
source: this.resource.toString()
|
||||
});
|
||||
}
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
|
||||
vscode.window.onDidChangeActiveTextEditor(editor => {
|
||||
this._register(vscode.window.onDidChangeActiveTextEditor(editor => {
|
||||
if (editor && isMarkdownFile(editor.document) && !this._locked) {
|
||||
this.update(editor.document.uri);
|
||||
}
|
||||
}, null, this._disposables);
|
||||
}));
|
||||
}
|
||||
|
||||
private readonly _onDisposeEmitter = new vscode.EventEmitter<void>();
|
||||
private readonly _onDisposeEmitter = this._register(new vscode.EventEmitter<void>());
|
||||
public readonly onDispose = this._onDisposeEmitter.event;
|
||||
|
||||
private readonly _onDidChangeViewStateEmitter = new vscode.EventEmitter<vscode.WebviewPanelOnDidChangeViewStateEvent>();
|
||||
private readonly _onDidChangeViewStateEmitter = this._register(new vscode.EventEmitter<vscode.WebviewPanelOnDidChangeViewStateEvent>());
|
||||
public readonly onDidChangeViewState = this._onDidChangeViewStateEmitter.event;
|
||||
|
||||
public get resource(): vscode.Uri {
|
||||
@@ -264,7 +265,8 @@ export class MarkdownPreview extends Disposable {
|
||||
locked: this._locked,
|
||||
line: this.line,
|
||||
resourceColumn: this.resourceColumn,
|
||||
imageInfo: this.imageInfo
|
||||
imageInfo: this.imageInfo,
|
||||
fragment: this.scrollToFragment
|
||||
};
|
||||
}
|
||||
|
||||
@@ -284,8 +286,12 @@ export class MarkdownPreview extends Disposable {
|
||||
|
||||
public update(resource: vscode.Uri) {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
// Reposition scroll preview, position scroll to the top if active text editor
|
||||
// doesn't corresponds with preview
|
||||
if (editor && editor.document.uri.fsPath === resource.fsPath) {
|
||||
this.line = getVisibleLine(editor);
|
||||
} else {
|
||||
this.line = 0;
|
||||
}
|
||||
|
||||
// If we have changed resources, cancel any pending updates
|
||||
@@ -433,8 +439,8 @@ export class MarkdownPreview extends Disposable {
|
||||
if (this._resource === markdownResource) {
|
||||
const self = this;
|
||||
const resourceProvider: WebviewResourceProvider = {
|
||||
toWebviewResource: (resource) => {
|
||||
return this.editor.webview.toWebviewResource(normalizeResource(markdownResource, resource));
|
||||
asWebviewUri: (resource) => {
|
||||
return this.editor.webview.asWebviewUri(normalizeResource(markdownResource, resource));
|
||||
},
|
||||
get cspSource() { return self.editor.webview.cspSource; }
|
||||
};
|
||||
@@ -520,11 +526,15 @@ export class MarkdownPreview extends Disposable {
|
||||
}
|
||||
|
||||
private async onDidClickPreviewLink(path: string, fragment: string | undefined) {
|
||||
this.scrollToFragment = undefined;
|
||||
const config = vscode.workspace.getConfiguration('markdown', this.resource);
|
||||
const openLinks = config.get<string>('preview.openMarkdownLinks', 'inPreview');
|
||||
if (openLinks === 'inPreview') {
|
||||
const markdownLink = await resolveLinkToMarkdownFile(path);
|
||||
if (markdownLink) {
|
||||
if (fragment) {
|
||||
this.scrollToFragment = fragment;
|
||||
}
|
||||
this.update(markdownLink);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ export class MarkdownContentProvider {
|
||||
scrollEditorWithPreview: config.scrollEditorWithPreview,
|
||||
doubleClickToSwitchToEditor: config.doubleClickToSwitchToEditor,
|
||||
disableSecurityWarnings: this.cspArbiter.shouldDisableSecurityWarnings(),
|
||||
webviewResourceRoot: resourceProvider.toWebviewResource(markdownDocument.uri).toString(),
|
||||
webviewResourceRoot: resourceProvider.asWebviewUri(markdownDocument.uri).toString(),
|
||||
};
|
||||
|
||||
this.logger.log('provideTextDocumentContent', initialData);
|
||||
@@ -86,7 +86,7 @@ export class MarkdownContentProvider {
|
||||
data-state="${escapeAttribute(JSON.stringify(state || {}))}">
|
||||
<script src="${this.extensionResourcePath(resourceProvider, 'pre.js')}" nonce="${nonce}"></script>
|
||||
${this.getStyles(resourceProvider, sourceUri, config, state)}
|
||||
<base href="${resourceProvider.toWebviewResource(markdownDocument.uri)}">
|
||||
<base href="${resourceProvider.asWebviewUri(markdownDocument.uri)}">
|
||||
</head>
|
||||
<body class="vscode-body ${config.scrollBeyondLastLine ? 'scrollBeyondLastLine' : ''} ${config.wordWrap ? 'wordWrap' : ''} ${config.markEditorSelection ? 'showEditorSelection' : ''}">
|
||||
${body}
|
||||
@@ -110,7 +110,7 @@ export class MarkdownContentProvider {
|
||||
}
|
||||
|
||||
private extensionResourcePath(resourceProvider: WebviewResourceProvider, mediaFile: string): string {
|
||||
const webviewResource = resourceProvider.toWebviewResource(
|
||||
const webviewResource = resourceProvider.asWebviewUri(
|
||||
vscode.Uri.file(this.context.asAbsolutePath(path.join('media', mediaFile))));
|
||||
return webviewResource.toString();
|
||||
}
|
||||
@@ -126,17 +126,17 @@ export class MarkdownContentProvider {
|
||||
|
||||
// Assume it must be a local file
|
||||
if (path.isAbsolute(href)) {
|
||||
return resourceProvider.toWebviewResource(vscode.Uri.file(href)).toString();
|
||||
return resourceProvider.asWebviewUri(vscode.Uri.file(href)).toString();
|
||||
}
|
||||
|
||||
// Use a workspace relative path if there is a workspace
|
||||
const root = vscode.workspace.getWorkspaceFolder(resource);
|
||||
if (root) {
|
||||
return resourceProvider.toWebviewResource(vscode.Uri.file(path.join(root.uri.fsPath, href))).toString();
|
||||
return resourceProvider.asWebviewUri(vscode.Uri.file(path.join(root.uri.fsPath, href))).toString();
|
||||
}
|
||||
|
||||
// Otherwise look relative to the markdown file
|
||||
return resourceProvider.toWebviewResource(vscode.Uri.file(path.join(path.dirname(resource.fsPath), href))).toString();
|
||||
return resourceProvider.asWebviewUri(vscode.Uri.file(path.join(path.dirname(resource.fsPath), href))).toString();
|
||||
}
|
||||
|
||||
private computeCustomStyleSheetIncludes(resourceProvider: WebviewResourceProvider, resource: vscode.Uri, config: MarkdownPreviewConfiguration): string {
|
||||
@@ -176,7 +176,7 @@ export class MarkdownContentProvider {
|
||||
private getStyles(resourceProvider: WebviewResourceProvider, resource: vscode.Uri, config: MarkdownPreviewConfiguration, state?: any): string {
|
||||
const baseStyles: string[] = [];
|
||||
for (const resource of this.contributionProvider.contributions.previewStyles) {
|
||||
baseStyles.push(`<link rel="stylesheet" type="text/css" href="${escapeAttribute(resourceProvider.toWebviewResource(resource))}">`);
|
||||
baseStyles.push(`<link rel="stylesheet" type="text/css" href="${escapeAttribute(resourceProvider.asWebviewUri(resource))}">`);
|
||||
}
|
||||
|
||||
return `${baseStyles.join('\n')}
|
||||
@@ -188,7 +188,7 @@ export class MarkdownContentProvider {
|
||||
const out: string[] = [];
|
||||
for (const resource of this.contributionProvider.contributions.previewScripts) {
|
||||
out.push(`<script async
|
||||
src="${escapeAttribute(resourceProvider.toWebviewResource(resource))}"
|
||||
src="${escapeAttribute(resourceProvider.asWebviewUri(resource))}"
|
||||
nonce="${nonce}"
|
||||
charset="UTF-8"></script>`);
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ export class MarkdownEngine {
|
||||
return md;
|
||||
}
|
||||
|
||||
private tokenize(
|
||||
private tokenizeDocument(
|
||||
document: SkinnyTextDocument,
|
||||
config: MarkdownItConfig,
|
||||
engine: MarkdownIt
|
||||
@@ -131,25 +131,30 @@ export class MarkdownEngine {
|
||||
this.currentDocument = document.uri;
|
||||
this._slugCount = new Map<string, number>();
|
||||
|
||||
const text = document.getText();
|
||||
const tokens = engine.parse(text.replace(UNICODE_NEWLINE_REGEX, ''), {});
|
||||
const tokens = this.tokenizeString(document.getText(), engine);
|
||||
this._tokenCache.update(document, config, tokens);
|
||||
return tokens;
|
||||
}
|
||||
|
||||
// {{SQL CARBON EDIT}} - Add renderText method
|
||||
public async renderText(document: vscode.Uri, text: string): Promise<string> {
|
||||
public async renderText(document: vscode.Uri, text: string): Promise<string> { // {{SQL CARBON EDIT}} - Add renderText method
|
||||
const config = this.getConfig(document);
|
||||
const engine = await this.getEngine(config);
|
||||
this.currentDocument = document;
|
||||
return engine.render(text, config);
|
||||
}
|
||||
// {{SQL CARBON EDIT}} - End
|
||||
|
||||
public async render(document: SkinnyTextDocument): Promise<string> {
|
||||
const config = this.getConfig(document.uri);
|
||||
private tokenizeString(text: string, engine: MarkdownIt) {
|
||||
return engine.parse(text.replace(UNICODE_NEWLINE_REGEX, ''), {});
|
||||
}
|
||||
|
||||
public async render(input: SkinnyTextDocument | string): Promise<string> {
|
||||
const config = this.getConfig(typeof input === 'string' ? undefined : input.uri);
|
||||
const engine = await this.getEngine(config);
|
||||
return engine.renderer.render(this.tokenize(document, config, engine), {
|
||||
const tokens = typeof input === 'string'
|
||||
? this.tokenizeString(input, engine)
|
||||
: this.tokenizeDocument(input, config, engine);
|
||||
|
||||
return engine.renderer.render(tokens, {
|
||||
...(engine as any).options,
|
||||
...config
|
||||
}, {});
|
||||
@@ -158,14 +163,14 @@ export class MarkdownEngine {
|
||||
public async parse(document: SkinnyTextDocument): Promise<Token[]> {
|
||||
const config = this.getConfig(document.uri);
|
||||
const engine = await this.getEngine(config);
|
||||
return this.tokenize(document, config, engine);
|
||||
return this.tokenizeDocument(document, config, engine);
|
||||
}
|
||||
|
||||
public cleanCache(): void {
|
||||
this._tokenCache.clean();
|
||||
}
|
||||
|
||||
private getConfig(resource: vscode.Uri): MarkdownItConfig {
|
||||
private getConfig(resource?: vscode.Uri): MarkdownItConfig {
|
||||
const config = vscode.workspace.getConfiguration('markdown', resource);
|
||||
return {
|
||||
breaks: config.get<boolean>('preview.breaks', false),
|
||||
@@ -306,13 +311,13 @@ async function getMarkdownOptions(md: () => MarkdownIt) {
|
||||
html: true,
|
||||
highlight: (str: string, lang?: string) => {
|
||||
// Workaround for highlight not supporting tsx: https://github.com/isagalaev/highlight.js/issues/1155
|
||||
if (lang && ['tsx', 'typescriptreact'].indexOf(lang.toLocaleLowerCase()) >= 0) {
|
||||
if (lang && ['tsx', 'typescriptreact'].includes(lang.toLocaleLowerCase())) {
|
||||
lang = 'jsx';
|
||||
}
|
||||
if (lang && lang.toLocaleLowerCase() === 'json5') {
|
||||
lang = 'json';
|
||||
}
|
||||
if (lang && lang.toLocaleLowerCase() === 'c#') {
|
||||
if (lang && ['c#', 'csharp'].includes(lang.toLocaleLowerCase())) {
|
||||
lang = 'cs';
|
||||
}
|
||||
if (lang && hljs.getLanguage(lang)) {
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import * as vscode from 'vscode';
|
||||
import 'mocha';
|
||||
|
||||
import { InMemoryDocument } from './inMemoryDocument';
|
||||
import { createNewMarkdownEngine } from './engine';
|
||||
|
||||
const testFileName = vscode.Uri.file('test.md');
|
||||
|
||||
suite('markdown.engine', () => {
|
||||
suite('rendering', () => {
|
||||
const input = '# hello\n\nworld!';
|
||||
const output = '<h1 id="hello" data-line="0" class="code-line">hello</h1>\n'
|
||||
+ '<p data-line="2" class="code-line">world!</p>\n';
|
||||
|
||||
test('Renders a document', async () => {
|
||||
const doc = new InMemoryDocument(testFileName, input);
|
||||
const engine = createNewMarkdownEngine();
|
||||
assert.strictEqual(await engine.render(doc), output);
|
||||
});
|
||||
|
||||
test('Renders a string', async () => {
|
||||
const engine = createNewMarkdownEngine();
|
||||
assert.strictEqual(await engine.render(input), output);
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -6,7 +6,7 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export interface WebviewResourceProvider {
|
||||
toWebviewResource(resource: vscode.Uri): vscode.Uri;
|
||||
asWebviewUri(resource: vscode.Uri): vscode.Uri;
|
||||
|
||||
readonly cspSource: string;
|
||||
}
|
||||
@@ -30,4 +30,4 @@ export function normalizeResource(
|
||||
}
|
||||
}
|
||||
return resource;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import { ApiWrapper } from './apiWrapper';
|
||||
import { UploadFilesCommand, MkDirCommand, SaveFileCommand, PreviewFileCommand, CopyPathCommand, DeleteFilesCommand } from './objectExplorerNodeProvider/hdfsCommands';
|
||||
import { IPrompter } from './prompts/question';
|
||||
import CodeAdapter from './prompts/adapter';
|
||||
import { mssql } from './mssql';
|
||||
import { IExtension } from './mssql';
|
||||
import { OpenSparkJobSubmissionDialogCommand, OpenSparkJobSubmissionDialogFromFileCommand, OpenSparkJobSubmissionDialogTask } from './sparkFeature/dialog/dialogCommands';
|
||||
import { OpenSparkYarnHistoryTask } from './sparkFeature/historyTask';
|
||||
import { MssqlObjectExplorerNodeProvider, mssqlOutputChannel } from './objectExplorerNodeProvider/objectExplorerNodeProvider';
|
||||
@@ -32,7 +32,7 @@ import { SqlToolsServer } from './sqlToolsServer';
|
||||
const msgSampleCodeDataFrame = localize('msgSampleCodeDataFrame', 'This sample code loads the file into a data frame and shows the first 10 results.');
|
||||
|
||||
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<mssql> {
|
||||
export async function activate(context: vscode.ExtensionContext): Promise<IExtension> {
|
||||
// lets make sure we support this platform first
|
||||
let supported = await Utils.verifyPlatform();
|
||||
|
||||
|
||||
2
extensions/mssql/src/mssql.d.ts
vendored
2
extensions/mssql/src/mssql.d.ts
vendored
@@ -23,7 +23,7 @@ export const enum extension {
|
||||
/**
|
||||
* The APIs provided by Mssql extension
|
||||
*/
|
||||
export interface mssql {
|
||||
export interface IExtension {
|
||||
/**
|
||||
* Gets the object explorer API that supports querying over the connections supported by this extension
|
||||
*
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { AppContext } from './appContext';
|
||||
import { mssql, ICmsService, IDacFxService, ISchemaCompareService, MssqlObjectExplorerBrowser } from './mssql';
|
||||
import { IExtension, ICmsService, IDacFxService, ISchemaCompareService, MssqlObjectExplorerBrowser } from './mssql';
|
||||
import * as constants from './constants';
|
||||
import { MssqlObjectExplorerNodeProvider } from './objectExplorerNodeProvider/objectExplorerNodeProvider';
|
||||
import * as azdata from 'azdata';
|
||||
|
||||
export function createMssqlApi(context: AppContext): mssql {
|
||||
export function createMssqlApi(context: AppContext): IExtension {
|
||||
return {
|
||||
get cmsService() {
|
||||
return context.getService<ICmsService>(constants.CmsService);
|
||||
|
||||
@@ -471,7 +471,7 @@ export class SchemaCompareOptionsDialog {
|
||||
}
|
||||
|
||||
private async reset() {
|
||||
let service = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.mssql).schemaCompare;
|
||||
let service = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.IExtension).schemaCompare;
|
||||
let result = await service.schemaCompareGetDefaultOptions();
|
||||
this.deploymentOptions = result.defaultDeploymentOptions;
|
||||
this.optionsChanged = true;
|
||||
|
||||
@@ -1012,7 +1012,7 @@ export class SchemaCompareMainWindow {
|
||||
}
|
||||
|
||||
private static async getService(providerName: string): Promise<mssql.ISchemaCompareService> {
|
||||
let service = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.mssql).schemaCompare;
|
||||
let service = (vscode.extensions.getExtension(mssql.extension.name).exports as mssql.IExtension).schemaCompare;
|
||||
return service;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user