mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-27 17:23:21 -05:00
* Merge from vscode bead496a613e475819f89f08e9e882b841bc1fe8 * Bump distro * Upgrade GCC to 4.9 due to yarn install errors * Update build image * Fix bootstrap base url * Bump distro * Fix build errors * Update source map file * Disable checkbox for blocking migration issues (#15131) * disable checkbox for blocking issues * wip * disable checkbox fixes * fix strings * Remove duplicate tsec command * Default to off for tab color if settings not present * re-skip failing tests * Fix mocha error * Bump sqlite version & fix notebooks search view * Turn off esbuild warnings * Update esbuild log level * Fix overflowactionbar tests * Fix ts-ignore in dropdown tests * cleanup/fixes * Fix hygiene * Bundle in entire zone.js module * Remove extra constructor param * bump distro for web compile break * bump distro for web compile break v2 * Undo log level change * New distro * Fix integration test scripts * remove the "no yarn.lock changes" workflow * fix scripts v2 * Update unit test scripts * Ensure ads-kerberos2 updates in .vscodeignore * Try fix unit tests * Upload crash reports * remove nogpu * always upload crashes * Use bash script * Consolidate data/ext dir names * Create in tmp directory Co-authored-by: chlafreniere <hichise@gmail.com> Co-authored-by: Christopher Suh <chsuh@microsoft.com> Co-authored-by: chgagnon <chgagnon@microsoft.com>
151 lines
4.7 KiB
TypeScript
151 lines
4.7 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* 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 'mocha';
|
|
import * as vscode from 'vscode';
|
|
import { joinLines } from './util';
|
|
|
|
const testFileA = workspaceFile('a.md');
|
|
|
|
function workspaceFile(...segments: string[]) {
|
|
return vscode.Uri.joinPath(vscode.workspace.workspaceFolders![0].uri, ...segments);
|
|
}
|
|
|
|
async function getLinksForFile(file: vscode.Uri): Promise<vscode.DocumentLink[]> {
|
|
return (await vscode.commands.executeCommand<vscode.DocumentLink[]>('vscode.executeLinkProvider', file))!;
|
|
}
|
|
|
|
suite('Markdown Document links', () => {
|
|
|
|
setup(async () => {
|
|
// the tests make the assumption that link providers are already registered
|
|
await vscode.extensions.getExtension('vscode.markdown-language-features')!.activate();
|
|
});
|
|
|
|
teardown(async () => {
|
|
await vscode.commands.executeCommand('workbench.action.closeAllEditors');
|
|
});
|
|
|
|
test('Should navigate to markdown file', async () => {
|
|
await withFileContents(testFileA, '[b](b.md)');
|
|
|
|
const [link] = await getLinksForFile(testFileA);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(workspaceFile('b.md'));
|
|
});
|
|
|
|
test('Should navigate to markdown file with leading ./', async () => {
|
|
await withFileContents(testFileA, '[b](./b.md)');
|
|
|
|
const [link] = await getLinksForFile(testFileA);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(workspaceFile('b.md'));
|
|
});
|
|
|
|
test('Should navigate to markdown file with leading /', async () => {
|
|
await withFileContents(testFileA, '[b](./b.md)');
|
|
|
|
const [link] = await getLinksForFile(testFileA);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(workspaceFile('b.md'));
|
|
});
|
|
|
|
test('Should navigate to markdown file without file extension', async () => {
|
|
await withFileContents(testFileA, '[b](b)');
|
|
|
|
const [link] = await getLinksForFile(testFileA);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(workspaceFile('b.md'));
|
|
});
|
|
|
|
test('Should navigate to markdown file in directory', async () => {
|
|
await withFileContents(testFileA, '[b](sub/c)');
|
|
|
|
const [link] = await getLinksForFile(testFileA);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(workspaceFile('sub', 'c.md'));
|
|
});
|
|
|
|
test('Should navigate to fragment by title in file', async () => {
|
|
await withFileContents(testFileA, '[b](sub/c#second)');
|
|
|
|
const [link] = await getLinksForFile(testFileA);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(workspaceFile('sub', 'c.md'));
|
|
assert.strictEqual(vscode.window.activeTextEditor!.selection.start.line, 1);
|
|
});
|
|
|
|
test('Should navigate to fragment by line', async () => {
|
|
await withFileContents(testFileA, '[b](sub/c#L2)');
|
|
|
|
const [link] = await getLinksForFile(testFileA);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(workspaceFile('sub', 'c.md'));
|
|
assert.strictEqual(vscode.window.activeTextEditor!.selection.start.line, 1);
|
|
});
|
|
|
|
test('Should navigate to fragment within current file', async () => {
|
|
await withFileContents(testFileA, joinLines(
|
|
'[](a#header)',
|
|
'[](#header)',
|
|
'# Header'));
|
|
|
|
const links = await getLinksForFile(testFileA);
|
|
{
|
|
await executeLink(links[0]);
|
|
assertActiveDocumentUri(workspaceFile('a.md'));
|
|
assert.strictEqual(vscode.window.activeTextEditor!.selection.start.line, 2);
|
|
}
|
|
{
|
|
await executeLink(links[1]);
|
|
assertActiveDocumentUri(workspaceFile('a.md'));
|
|
assert.strictEqual(vscode.window.activeTextEditor!.selection.start.line, 2);
|
|
}
|
|
});
|
|
|
|
test('Should navigate to fragment within current untitled file', async () => {
|
|
const testFile = workspaceFile('x.md').with({ scheme: 'untitled' });
|
|
await withFileContents(testFile, joinLines(
|
|
'[](#second)',
|
|
'# Second'));
|
|
|
|
const [link] = await getLinksForFile(testFile);
|
|
await executeLink(link);
|
|
|
|
assertActiveDocumentUri(testFile);
|
|
assert.strictEqual(vscode.window.activeTextEditor!.selection.start.line, 1);
|
|
});
|
|
});
|
|
|
|
|
|
function assertActiveDocumentUri(expectedUri: vscode.Uri) {
|
|
assert.strictEqual(
|
|
vscode.window.activeTextEditor!.document.uri.fsPath,
|
|
expectedUri.fsPath
|
|
);
|
|
}
|
|
|
|
async function withFileContents(file: vscode.Uri, contents: string): Promise<void> {
|
|
const document = await vscode.workspace.openTextDocument(file);
|
|
const editor = await vscode.window.showTextDocument(document);
|
|
await editor.edit(edit => {
|
|
edit.replace(new vscode.Range(0, 0, 1000, 0), contents);
|
|
});
|
|
}
|
|
|
|
async function executeLink(link: vscode.DocumentLink) {
|
|
const args = JSON.parse(decodeURIComponent(link.target!.query));
|
|
await vscode.commands.executeCommand(link.target!.path, args);
|
|
}
|
|
|