diff options
Diffstat (limited to 'extensions')
24 files changed, 394 insertions, 120 deletions
diff --git a/extensions/git/extension.webpack.config.js b/extensions/git/extension.webpack.config.js index 5efa2052e88..3324b6c1d98 100644 --- a/extensions/git/extension.webpack.config.js +++ b/extensions/git/extension.webpack.config.js @@ -13,6 +13,7 @@ module.exports = withDefaults({ context: __dirname, entry: { main: './src/main.ts', - ['askpass-main']: './src/askpass-main.ts' + ['askpass-main']: './src/askpass-main.ts', + ['git-editor-main']: './src/git-editor-main.ts' } }); diff --git a/extensions/git/package.json b/extensions/git/package.json index e2428b5e02f..111717f86c9 100644 --- a/extensions/git/package.json +++ b/extensions/git/package.json @@ -14,6 +14,7 @@ "contribMergeEditorToolbar", "contribViewsWelcome", "scmActionButton", + "scmInput", "scmSelectedProvider", "scmValidation", "timeline" @@ -213,83 +214,99 @@ "command": "git.commit", "title": "%command.commit%", "category": "Git", - "icon": "$(check)" + "icon": "$(check)", + "enablement": "!commitInProgress" }, { "command": "git.commitStaged", "title": "%command.commitStaged%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitEmpty", "title": "%command.commitEmpty%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitStagedSigned", "title": "%command.commitStagedSigned%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitStagedAmend", "title": "%command.commitStagedAmend%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitAll", "title": "%command.commitAll%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitAllSigned", "title": "%command.commitAllSigned%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitAllAmend", "title": "%command.commitAllAmend%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitNoVerify", "title": "%command.commitNoVerify%", "category": "Git", - "icon": "$(check)" + "icon": "$(check)", + "enablement": "!commitInProgress" }, { "command": "git.commitStagedNoVerify", "title": "%command.commitStagedNoVerify%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitEmptyNoVerify", "title": "%command.commitEmptyNoVerify%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitStagedSignedNoVerify", "title": "%command.commitStagedSignedNoVerify%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitStagedAmendNoVerify", "title": "%command.commitStagedAmendNoVerify%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitAllNoVerify", "title": "%command.commitAllNoVerify%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitAllSignedNoVerify", "title": "%command.commitAllSignedNoVerify%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.commitAllAmendNoVerify", "title": "%command.commitAllAmendNoVerify%", - "category": "Git" + "category": "Git", + "enablement": "!commitInProgress" }, { "command": "git.restoreCommitTemplate", @@ -2013,6 +2030,18 @@ "scope": "machine", "description": "%config.defaultCloneDirectory%" }, + "git.useEditorAsCommitInput": { + "type": "boolean", + "scope": "resource", + "description": "%config.useEditorAsCommitInput%", + "default": false + }, + "git.verboseCommit": { + "type": "boolean", + "scope": "resource", + "markdownDescription": "%config.verboseCommit%", + "default": false + }, "git.enableSmartCommit": { "type": "boolean", "scope": "resource", diff --git a/extensions/git/package.nls.json b/extensions/git/package.nls.json index b729f821b61..5210e64de80 100644 --- a/extensions/git/package.nls.json +++ b/extensions/git/package.nls.json @@ -140,6 +140,8 @@ "config.ignoreLimitWarning": "Ignores the warning when there are too many changes in a repository.", "config.ignoreRebaseWarning": "Ignores the warning when it looks like the branch might have been rebased when pulling.", "config.defaultCloneDirectory": "The default location to clone a git repository.", + "config.useEditorAsCommitInput": "Use an editor to author the commit message.", + "config.verboseCommit": "Enable verbose output when `#git.useEditorAsCommitInput#` is enabled.", "config.enableSmartCommit": "Commit all changes when there are no staged changes.", "config.smartCommitChanges": "Control which changes are automatically staged by Smart Commit.", "config.smartCommitChanges.all": "Automatically stage all changes.", diff --git a/extensions/git/src/api/git.d.ts b/extensions/git/src/api/git.d.ts index 4b180dac920..14c7447e3e8 100644 --- a/extensions/git/src/api/git.d.ts +++ b/extensions/git/src/api/git.d.ts @@ -137,6 +137,8 @@ export interface CommitOptions { empty?: boolean; noVerify?: boolean; requireUserConfig?: boolean; + useEditor?: boolean; + verbose?: boolean; } export interface FetchOptions { @@ -336,4 +338,5 @@ export const enum GitErrorCodes { PatchDoesNotApply = 'PatchDoesNotApply', NoPathFound = 'NoPathFound', UnknownPath = 'UnknownPath', + EmptyCommitMessage = 'EmptyCommitMessage' } diff --git a/extensions/git/src/askpass.ts b/extensions/git/src/askpass.ts index 2f9678c6e04..d9d9378f8aa 100644 --- a/extensions/git/src/askpass.ts +++ b/extensions/git/src/askpass.ts @@ -6,9 +6,8 @@ import { window, InputBoxOptions, Uri, Disposable, workspace } from 'vscode'; import { IDisposable, EmptyDisposable, toDisposable } from './util'; import * as path from 'path'; -import { IIPCHandler, IIPCServer, createIPCServer } from './ipc/ipcServer'; +import { IIPCHandler, IIPCServer } from './ipc/ipcServer'; import { CredentialsProvider, Credentials } from './api/git'; -import { OutputChannelLogger } from './log'; export class Askpass implements IIPCHandler { @@ -16,16 +15,7 @@ export class Askpass implements IIPCHandler { private cache = new Map<string, Credentials>(); private credentialsProviders = new Set<CredentialsProvider>(); - static async create(outputChannelLogger: OutputChannelLogger, context?: string): Promise<Askpass> { - try { - return new Askpass(await createIPCServer(context)); - } catch (err) { - outputChannelLogger.logError(`Failed to create git askpass IPC: ${err}`); - return new Askpass(); - } - } - - private constructor(private ipc?: IIPCServer) { + constructor(private ipc?: IIPCServer) { if (ipc) { this.disposable = ipc.registerHandler('askpass', this); } diff --git a/extensions/git/src/commands.ts b/extensions/git/src/commands.ts index cd43dc2ea6e..e3968df3a0d 100644 --- a/extensions/git/src/commands.ts +++ b/extensions/git/src/commands.ts @@ -1516,6 +1516,14 @@ export class CommandCenter { opts.signoff = true; } + if (config.get<boolean>('useEditorAsCommitInput')) { + opts.useEditor = true; + + if (config.get<boolean>('verboseCommit')) { + opts.verbose = true; + } + } + const smartCommitChanges = config.get<'all' | 'tracked'>('smartCommitChanges'); if ( @@ -1563,7 +1571,7 @@ export class CommandCenter { const message = await getCommitMessage(); - if (!message && !opts.amend) { + if (!message && !opts.amend && !opts.useEditor) { return false; } @@ -1623,10 +1631,13 @@ export class CommandCenter { private async commitWithAnyInput(repository: Repository, opts?: CommitOptions): Promise<void> { const message = repository.inputBox.value; + const root = Uri.file(repository.root); + const config = workspace.getConfiguration('git', root); + const getCommitMessage = async () => { let _message: string | undefined = message; - if (!_message) { + if (!_message && !config.get<boolean>('useEditorAsCommitInput')) { const value: string | undefined = undefined; if (opts && opts.amend && repository.HEAD && repository.HEAD.commit) { @@ -3010,7 +3021,7 @@ export class CommandCenter { }; let message: string; - let type: 'error' | 'warning' = 'error'; + let type: 'error' | 'warning' | 'information' = 'error'; const choices = new Map<string, () => void>(); const openOutputChannelChoice = localize('open git log', "Open Git Log"); @@ -3073,6 +3084,12 @@ export class CommandCenter { message = localize('missing user info', "Make sure you configure your 'user.name' and 'user.email' in git."); choices.set(localize('learn more', "Learn More"), () => commands.executeCommand('vscode.open', Uri.parse('https://aka.ms/vscode-setup-git'))); break; + case GitErrorCodes.EmptyCommitMessage: + message = localize('empty commit', "Commit operation was cancelled due to empty commit message."); + choices.clear(); + type = 'information'; + options.modal = false; + break; default: { const hint = (err.stderr || err.message || String(err)) .replace(/^error: /mi, '') @@ -3094,10 +3111,20 @@ export class CommandCenter { return; } + let result: string | undefined; const allChoices = Array.from(choices.keys()); - const result = type === 'error' - ? await window.showErrorMessage(message, options, ...allChoices) - : await window.showWarningMessage(message, options, ...allChoices); + + switch (type) { + case 'error': + result = await window.showErrorMessage(message, options, ...allChoices); + break; + case 'warning': + result = await window.showWarningMessage(message, options, ...allChoices); + break; + case 'information': + result = await window.showInformationMessage(message, options, ...allChoices); + break; + } if (result) { const resultFn = choices.get(result); diff --git a/extensions/git/src/git-editor-empty.sh b/extensions/git/src/git-editor-empty.sh new file mode 100755 index 00000000000..1a2485251c3 --- /dev/null +++ b/extensions/git/src/git-editor-empty.sh @@ -0,0 +1 @@ +#!/bin/sh diff --git a/extensions/git/src/git-editor-main.ts b/extensions/git/src/git-editor-main.ts new file mode 100644 index 00000000000..eb4da4a40b5 --- /dev/null +++ b/extensions/git/src/git-editor-main.ts @@ -0,0 +1,21 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import { IPCClient } from './ipc/ipcClient'; + +function fatal(err: any): void { + console.error(err); + process.exit(1); +} + +function main(argv: string[]): void { + const ipcClient = new IPCClient('git-editor'); + const commitMessagePath = argv[argv.length - 1]; + + ipcClient.call({ commitMessagePath }).then(() => { + setTimeout(() => process.exit(0), 0); + }).catch(err => fatal(err)); +} + +main(process.argv); diff --git a/extensions/git/src/git-editor.sh b/extensions/git/src/git-editor.sh new file mode 100755 index 00000000000..1c45c2deac1 --- /dev/null +++ b/extensions/git/src/git-editor.sh @@ -0,0 +1,4 @@ +#!/bin/sh + +ELECTRON_RUN_AS_NODE="1" \ +"$VSCODE_GIT_EDITOR_NODE" "$VSCODE_GIT_EDITOR_MAIN" $VSCODE_GIT_EDITOR_EXTRA_ARGS $@ diff --git a/extensions/git/src/git.ts b/extensions/git/src/git.ts index 203d6949897..5e7ddef8599 100644 --- a/extensions/git/src/git.ts +++ b/extensions/git/src/git.ts @@ -1400,20 +1400,37 @@ export class Repository { } async commit(message: string | undefined, opts: CommitOptions = Object.create(null)): Promise<void> { - const args = ['commit', '--quiet', '--allow-empty-message']; + const args = ['commit', '--quiet']; + const options: SpawnOptions = {}; + + if (message) { + options.input = message; + args.push('--file', '-'); + } + + if (opts.verbose) { + args.push('--verbose'); + } if (opts.all) { args.push('--all'); } - if (opts.amend && message) { + if (opts.amend) { args.push('--amend'); } - if (opts.amend && !message) { - args.push('--amend', '--no-edit'); - } else { - args.push('--file', '-'); + if (!opts.useEditor) { + if (!message) { + if (opts.amend) { + args.push('--no-edit'); + } else { + options.input = ''; + args.push('--file', '-'); + } + } + + args.push('--allow-empty-message'); } if (opts.signoff) { @@ -1438,7 +1455,7 @@ export class Repository { } try { - await this.exec(args, !opts.amend || message ? { input: message || '' } : {}); + await this.exec(args, options); } catch (commitErr) { await this.handleCommitError(commitErr); } @@ -1462,6 +1479,9 @@ export class Repository { if (/not possible because you have unmerged files/.test(commitErr.stderr || '')) { commitErr.gitErrorCode = GitErrorCodes.UnmergedChanges; throw commitErr; + } else if (/Aborting commit due to empty commit message/.test(commitErr.stderr || '')) { + commitErr.gitErrorCode = GitErrorCodes.EmptyCommitMessage; + throw commitErr; } try { diff --git a/extensions/git/src/gitEditor.ts b/extensions/git/src/gitEditor.ts new file mode 100644 index 00000000000..5f65a7dbcf2 --- /dev/null +++ b/extensions/git/src/gitEditor.ts @@ -0,0 +1,65 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +import * as path from 'path'; +import { TabInputText, Uri, window, workspace } from 'vscode'; +import { IIPCHandler, IIPCServer } from './ipc/ipcServer'; +import { EmptyDisposable, IDisposable } from './util'; + +interface GitEditorRequest { + commitMessagePath?: string; +} + +export class GitEditor implements IIPCHandler { + + private disposable: IDisposable = EmptyDisposable; + + constructor(private ipc?: IIPCServer) { + if (ipc) { + this.disposable = ipc.registerHandler('git-editor', this); + } + } + + async handle({ commitMessagePath }: GitEditorRequest): Promise<any> { + if (commitMessagePath) { + const uri = Uri.file(commitMessagePath); + const doc = await workspace.openTextDocument(uri); + await window.showTextDocument(doc, { preview: false }); + + return new Promise((c) => { + const onDidClose = window.tabGroups.onDidChangeTabs(async (tabs) => { + if (tabs.closed.some(t => t.input instanceof TabInputText && t.input.uri.toString() === uri.toString())) { + onDidClose.dispose(); + return c(true); + } + }); + }); + } + } + + getEnv(): { [key: string]: string } { + if (!this.ipc) { + return { + GIT_EDITOR: `"${path.join(__dirname, 'git-editor-empty.sh')}"` + }; + } + + let env: { [key: string]: string } = { + VSCODE_GIT_EDITOR_NODE: process.execPath, + VSCODE_GIT_EDITOR_EXTRA_ARGS: (process.versions['electron'] && process.versions['microsoft-build']) ? '--ms-enable-electron-run-as-node' : '', + VSCODE_GIT_EDITOR_MAIN: path.join(__dirname, 'git-editor-main.js') + }; + + const config = workspace.getConfiguration('git'); + if (config.get<boolean>('useEditorAsCommitInput')) { + env.GIT_EDITOR = `"${path.join(__dirname, 'git-editor.sh')}"`; + } + + return env; + } + + dispose(): void { + this.disposable.dispose(); + } +} diff --git a/extensions/git/src/main.ts b/extensions/git/src/main.ts index a5e7c060f00..46f612539fb 100644 --- a/extensions/git/src/main.ts +++ b/extensions/git/src/main.ts @@ -25,6 +25,8 @@ import { GitTimelineProvider } from './timelineProvider'; import { registerAPICommands } from './api/api1'; import { TerminalEnvironmentManager } from './terminal'; import { OutputChannelLogger } from './log'; +import { createIPCServer, IIPCServer } from './ipc/ipcServer'; +import { GitEditor } from './gitEditor'; const deactivateTasks: { (): Promise<any> }[] = []; @@ -60,10 +62,21 @@ async function createModel(context: ExtensionContext, outputChannelLogger: Outpu return !skip; }); - const askpass = await Askpass.create(outputChannelLogger, context.storagePath); + let ipc: IIPCServer | undefined = undefined; + + try { + ipc = await createIPCServer(context.storagePath); + } catch (err) { + outputChannelLogger.logError(`Failed to create git IPC: ${err}`); + } + + const askpass = new Askpass(ipc); disposables.push(askpass); - const environment = askpass.getEnv(); + const gitEditor = new GitEditor(ipc); + disposables.push(gitEditor); + + const environment = { ...askpass.getEnv(), ...gitEditor.getEnv() }; const terminalEnvironmentManager = new TerminalEnvironmentManager(context, environment); disposables.push(terminalEnvironmentManager); diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 69c184209fa..c6fa51b5497 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -454,6 +454,13 @@ class ProgressManager { const onDidChange = filterEvent(workspace.onDidChangeConfiguration, e => e.affectsConfiguration('git', Uri.file(this.repository.root))); onDidChange(_ => this.updateEnablement()); this.updateEnablement(); + + this.repository.onDidChangeOperations(() => { + const commitInProgress = this.repository.operations.isRunning(Operation.Commit); + + this.repository.sourceControl.inputBox.enabled = !commitInProgress; + commands.executeCommand('setContext', 'commitInProgress', commitInProgress); + }); } private updateEnablement(): void { diff --git a/extensions/git/tsconfig.json b/extensions/git/tsconfig.json index 13997275056..1f1c02d3356 100644 --- a/extensions/git/tsconfig.json +++ b/extensions/git/tsconfig.json @@ -12,6 +12,7 @@ "../../src/vscode-dts/vscode.d.ts", "../../src/vscode-dts/vscode.proposed.diffCommand.d.ts", "../../src/vscode-dts/vscode.proposed.scmActionButton.d.ts", + "../../src/vscode-dts/vscode.proposed.scmInput.d.ts", "../../src/vscode-dts/vscode.proposed.scmSelectedProvider.d.ts", "../../src/vscode-dts/vscode.proposed.scmValidation.d.ts", "../../src/vscode-dts/vscode.proposed.tabs.d.ts", diff --git a/extensions/markdown-language-features/src/languageFeatures/copyPaste.ts b/extensions/markdown-language-features/src/languageFeatures/copyPaste.ts index d9e939b463c..c36403d06ee 100644 --- a/extensions/markdown-language-features/src/languageFeatures/copyPaste.ts +++ b/extensions/markdown-language-features/src/languageFeatures/copyPaste.ts @@ -4,23 +4,29 @@ *--------------------------------------------------------------------------------------------*/ import * as vscode from 'vscode'; -import { tryInsertUriList } from './dropIntoEditor'; +import { tryGetUriListSnippet } from './dropIntoEditor'; export function registerPasteProvider(selector: vscode.DocumentSelector) { return vscode.languages.registerDocumentPasteEditProvider(selector, new class implements vscode.DocumentPasteEditProvider { async provideDocumentPasteEdits( document: vscode.TextDocument, - range: vscode.Range, + _ranges: readonly vscode.Range[], dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken, - ): Promise<vscode.SnippetTextEdit | undefined> { + ): Promise<vscode.DocumentPasteEdit | undefined> { const enabled = vscode.workspace.getConfiguration('markdown', document).get('experimental.editor.pasteLinks.enabled', false); if (!enabled) { return; } - return tryInsertUriList(document, range, dataTransfer, token); + const snippet = await tryGetUriListSnippet(document, dataTransfer, token); + if (snippet) { + return { insertText: snippet }; + } + return undefined; } + }, { + pasteMimeTypes: ['text/uri-list'] }); } diff --git a/extensions/markdown-language-features/src/languageFeatures/dropIntoEditor.ts b/extensions/markdown-language-features/src/languageFeatures/dropIntoEditor.ts index 2ad71ec0516..01daa70085f 100644 --- a/extensions/markdown-language-features/src/languageFeatures/dropIntoEditor.ts +++ b/extensions/markdown-language-features/src/languageFeatures/dropIntoEditor.ts @@ -25,19 +25,22 @@ const imageFileExtensions = new Set<string>([ export function registerDropIntoEditor(selector: vscode.DocumentSelector) { return vscode.languages.registerDocumentOnDropEditProvider(selector, new class implements vscode.DocumentOnDropEditProvider { - async provideDocumentOnDropEdits(document: vscode.TextDocument, position: vscode.Position, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.SnippetTextEdit | undefined> { + async provideDocumentOnDropEdits(document: vscode.TextDocument, _position: vscode.Position, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.DocumentDropEdit | undefined> { const enabled = vscode.workspace.getConfiguration('markdown', document).get('editor.drop.enabled', true); if (!enabled) { - return; + return undefined; } - const replacementRange = new vscode.Range(position, position); - return tryInsertUriList(document, replacementRange, dataTransfer, token); + const snippet = await tryGetUriListSnippet(document, dataTransfer, token); + if (snippet) { + return { insertText: snippet }; + } + return undefined; } }); } -export async function tryInsertUriList(document: vscode.TextDocument, replacementRange: vscode.Range, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.SnippetTextEdit | undefined> { +export async function tryGetUriListSnippet(document: vscode.TextDocument, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.SnippetString | undefined> { const urlList = await dataTransfer.get('text/uri-list')?.asString(); if (!urlList || token.isCancellationRequested) { return undefined; @@ -72,5 +75,5 @@ export async function tryInsertUriList(document: vscode.TextDocument, replacemen } }); - return new vscode.SnippetTextEdit(replacementRange, snippet); + return snippet; } diff --git a/extensions/markdown-language-features/src/languageFeatures/rename.ts b/extensions/markdown-language-features/src/languageFeatures/rename.ts index db06b7eeb9c..955581b9d97 100644 --- a/extensions/markdown-language-features/src/languageFeatures/rename.ts +++ b/extensions/markdown-language-features/src/languageFeatures/rename.ts @@ -142,7 +142,7 @@ export class MdRenameProvider extends Disposable implements vscode.RenameProvide return this.renameExternalLink(allRefsInfo, newName); } else if (triggerRef.kind === 'header' || (triggerRef.kind === 'link' && triggerRef.link.source.fragmentRange?.contains(position) && (triggerRef.link.kind === 'definition' || triggerRef.link.kind === 'link' && triggerRef.link.href.kind === 'internal'))) { return this.renameFragment(allRefsInfo, newName); - } else if (triggerRef.kind === 'link' && !triggerRef.link.source.fragmentRange?.contains(position) && triggerRef.link.kind === 'link' && triggerRef.link.href.kind === 'internal') { + } else if (triggerRef.kind === 'link' && !triggerRef.link.source.fragmentRange?.contains(position) && (triggerRef.link.kind === 'link' || triggerRef.link.kind === 'definition') && triggerRef.link.href.kind === 'internal') { return this.renameFilePath(triggerRef.link.source.resource, triggerRef.link.href, allRefsInfo, newName); } diff --git a/extensions/markdown-language-features/src/test/rename.test.ts b/extensions/markdown-language-features/src/test/rename.test.ts index 53839071ea4..6560055823d 100644 --- a/extensions/markdown-language-features/src/test/rename.test.ts +++ b/extensions/markdown-language-features/src/test/rename.test.ts @@ -614,4 +614,79 @@ suite('markdown: rename', () => { ] }); }); + + test('Rename on definition path should update all references to path', async () => { + const uri = workspacePath('doc.md'); + const doc = new InMemoryDocument(uri, joinLines( + `[ref text][ref]`, + `[direct](/file)`, + `[ref]: /file`, // rename here + )); + + const workspace = new InMemoryWorkspaceMarkdownDocuments([doc]); + + const preparedInfo = await prepareRename(doc, new vscode.Position(2, 10), workspace); + assert.strictEqual(preparedInfo!.placeholder, '/file'); + assertRangeEqual(preparedInfo!.range, new vscode.Range(2, 7, 2, 12)); + + const edit = await getRenameEdits(doc, new vscode.Position(2, 10), "/newFile", workspace); + assertEditsEqual(edit!, { + uri, edits: [ + new vscode.TextEdit(new vscode.Range(1, 9, 1, 14), '/newFile'), + new vscode.TextEdit(new vscode.Range(2, 7, 2, 12), '/newFile'), + ] + }); + }); + + test('Rename on definition path where file exists should also update file', async () => { + const uri1 = workspacePath('doc.md'); + const doc1 = new InMemoryDocument(uri1, joinLines( + `[ref text][ref]`, + `[direct](/doc2)`, + `[ref]: /doc2`, // rename here + )); + + const uri2 = workspacePath('doc2.md'); + const doc2 = new InMemoryDocument(uri2, joinLines()); + + const workspace = new InMemoryWorkspaceMarkdownDocuments([doc1, doc2]); + + const preparedInfo = await prepareRename(doc1, new vscode.Position(2, 10), workspace); + assert.strictEqual(preparedInfo!.placeholder, '/doc2'); + assertRangeEqual(preparedInfo!.range, new vscode.Range(2, 7, 2, 12)); + + const edit = await getRenameEdits(doc1, new vscode.Position(2, 10), "/new-doc", workspace); + assertEditsEqual(edit!, { + uri: uri1, edits: [ + new vscode.TextEdit(new vscode.Range(1, 9, 1, 14), '/new-doc'), + new vscode.TextEdit(new vscode.Range(2, 7, 2, 12), '/new-doc'), + ] + }, { + originalUri: uri2, + newUri: workspacePath('new-doc.md') + }); + }); + + test('Rename on definition path header should update all references to header', async () => { + const uri = workspacePath('doc.md'); + const doc = new InMemoryDocument(uri, joinLines( + `[ref text][ref]`, + `[direct](/file#header)`, + `[ref]: /file#header`, // rename here + )); + + const workspace = new InMemoryWorkspaceMarkdownDocuments([doc]); + + const preparedInfo = await prepareRename(doc, new vscode.Position(2, 16), workspace); + assert.strictEqual(preparedInfo!.placeholder, 'header'); + assertRangeEqual(preparedInfo!.range, new vscode.Range(2, 13, 2, 19)); + + const edit = await getRenameEdits(doc, new vscode.Position(2, 16), "New Header", workspace); + assertEditsEqual(edit!, { + uri, edits: [ + new vscode.TextEdit(new vscode.Range(1, 15, 1, 21), 'new-header'), + new vscode.TextEdit(new vscode.Range(2, 13, 2, 19), 'new-header'), + ] + }); + }); }); diff --git a/extensions/npm/src/tasks.ts b/extensions/npm/src/tasks.ts index dc28ed7f4ed..676914a2dfb 100644 --- a/extensions/npm/src/tasks.ts +++ b/extensions/npm/src/tasks.ts @@ -12,10 +12,12 @@ import * as path from 'path'; import * as fs from 'fs'; import * as minimatch from 'minimatch'; import * as nls from 'vscode-nls'; +import { Utils } from 'vscode-uri'; import { findPreferredPM } from './preferred-pm'; import { readScripts } from './readScripts'; const localize = nls.loadMessageBundle(); +const excludeRegex = new RegExp('^(node_modules|.vscode-test)$', 'i'); export interface INpmTaskDefinition extends TaskDefinition { script: string; @@ -156,7 +158,7 @@ export async function hasNpmScripts(): Promise<boolean> { } try { for (const folder of folders) { - if (isAutoDetectionEnabled(folder)) { + if (isAutoDetectionEnabled(folder) && !excludeRegex.test(Utils.basename(folder.uri))) { const relativePattern = new RelativePattern(folder, '**/package.json'); const paths = await workspace.findFiles(relativePattern, '**/node_modules/**'); if (paths.length > 0) { @@ -182,7 +184,7 @@ async function detectNpmScripts(context: ExtensionContext, showWarning: boolean) } try { for (const folder of folders) { - if (isAutoDetectionEnabled(folder)) { + if (isAutoDetectionEnabled(folder) && !excludeRegex.test(Utils.basename(folder.uri))) { const relativePattern = new RelativePattern(folder, '**/package.json'); const paths = await workspace.findFiles(relativePattern, '**/{node_modules,.vscode-test}/**'); for (const path of paths) { @@ -206,6 +208,9 @@ export async function detectNpmScriptsForFolder(context: ExtensionContext, folde const folderTasks: IFolderTaskItem[] = []; try { + if (excludeRegex.test(Utils.basename(folder))) { + return folderTasks; + } const relativePattern = new RelativePattern(folder.fsPath, '**/package.json'); const paths = await workspace.findFiles(relativePattern, '**/node_modules/**'); diff --git a/extensions/theme-tomorrow-night-blue/themes/tomorrow-night-blue-color-theme.json b/extensions/theme-tomorrow-night-blue/themes/tomorrow-night-blue-color-theme.json index 70b57d594fe..b37fd6b0083 100644 --- a/extensions/theme-tomorrow-night-blue/themes/tomorrow-night-blue-color-theme.json +++ b/extensions/theme-tomorrow-night-blue/themes/tomorrow-night-blue-color-theme.json @@ -65,7 +65,7 @@ } }, { - "scope": ["meta.embedded", "source.groovy.embedded"], + "scope": ["meta.embedded", "source.groovy.embedded", "meta.jsx.children"], "settings": { //"background": "#002451", "foreground": "#FFFFFF" diff --git a/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts b/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts index c35aa35aee0..bc0ac10388b 100644 --- a/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts +++ b/extensions/typescript-language-features/src/languageFeatures/fileConfigurationManager.ts @@ -174,6 +174,7 @@ export default class FileConfigurationManager extends Disposable { document); const preferences: Proto.UserPreferences = { + ...config.get('unstable'), quotePreference: this.getQuoteStylePreference(preferencesConfig), importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig), importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig), diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/ipynb.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/ipynb.test.ts index 44359de5e84..b73025ab2e7 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/ipynb.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/ipynb.test.ts @@ -18,9 +18,9 @@ import * as vscode from 'vscode'; const notebookEditor = vscode.window.activeNotebookEditor; assert.ok(notebookEditor); - assert.strictEqual(notebookEditor.document.cellCount, 2); - assert.strictEqual(notebookEditor.document.cellAt(0).kind, vscode.NotebookCellKind.Markup); - assert.strictEqual(notebookEditor.document.cellAt(1).kind, vscode.NotebookCellKind.Code); - assert.strictEqual(notebookEditor.document.cellAt(1).outputs.length, 1); + assert.strictEqual(notebookEditor.notebook.cellCount, 2); + assert.strictEqual(notebookEditor.notebook.cellAt(0).kind, vscode.NotebookCellKind.Markup); + assert.strictEqual(notebookEditor.notebook.cellAt(1).kind, vscode.NotebookCellKind.Code); + assert.strictEqual(notebookEditor.notebook.cellAt(1).outputs.length, 1); }); }); diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts index 21b798dfbfd..12b79163769 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.editor.test.ts @@ -75,11 +75,11 @@ import * as utils from '../utils'; const uri = await utils.createRandomFile(undefined, undefined, '.nbdtest'); const editor = await vscode.window.showNotebookDocument(uri); - assert.strictEqual(uri.toString(), editor.document.uri.toString()); + assert.strictEqual(uri.toString(), editor.notebook.uri.toString()); - assert.strictEqual(notebookDocumentsFromOnDidOpen.has(editor.document), true); + assert.strictEqual(notebookDocumentsFromOnDidOpen.has(editor.notebook), true); - const includes = vscode.workspace.notebookDocuments.includes(editor.document); + const includes = vscode.workspace.notebookDocuments.includes(editor.notebook); assert.strictEqual(true, includes); sub.dispose(); @@ -104,7 +104,7 @@ import * as utils from '../utils'; const resource = await utils.createRandomFile(undefined, undefined, '.nbdtest'); const editor = await vscode.window.showNotebookDocument(resource); assert.ok(await openedEditor); - assert.strictEqual(editor.document.uri.toString(), resource.toString()); + assert.strictEqual(editor.notebook.uri.toString(), resource.toString()); }); test('Active/Visible Editor', async function () { diff --git a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts index f863bf014b6..c4d4733578a 100644 --- a/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts +++ b/extensions/vscode-api-tests/src/singlefolder-tests/notebook.test.ts @@ -77,7 +77,7 @@ export class Kernel { function getFocusedCell(editor?: vscode.NotebookEditor) { - return editor ? editor.document.cellAt(editor.selections[0].start) : undefined; + return editor ? editor.notebook.cellAt(editor.selections[0].start) : undefined; } async function assertKernel(kernel: Kernel, notebook: vscode.NotebookDocument): Promise<void> { @@ -204,12 +204,12 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const cellsChangeEvent = asPromise<vscode.NotebookDocumentChangeEvent>(vscode.workspace.onDidChangeNotebookDocument); await vscode.commands.executeCommand('notebook.cell.insertCodeCellBelow'); const cellChangeEventRet = await cellsChangeEvent; - assert.strictEqual(cellChangeEventRet.notebook, editor.document); + assert.strictEqual(cellChangeEventRet.notebook, editor.notebook); assert.strictEqual(cellChangeEventRet.contentChanges.length, 1); assert.deepStrictEqual(cellChangeEventRet.contentChanges[0], <vscode.NotebookDocumentContentChange>{ range: new vscode.NotebookRange(1, 1), removedCells: [], - addedCells: [editor.document.cellAt(1)] + addedCells: [editor.notebook.cellAt(1)] }); const moveCellEvent = asPromise<vscode.NotebookDocumentChangeEvent>(vscode.workspace.onDidChangeNotebookDocument); @@ -220,11 +220,11 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('notebook.cell.execute'); const cellOutputsAddedRet = await cellOutputChange; - assert.strictEqual(cellOutputsAddedRet.notebook.uri.toString(), editor.document.uri.toString()); + assert.strictEqual(cellOutputsAddedRet.notebook.uri.toString(), editor.notebook.uri.toString()); assert.strictEqual(cellOutputsAddedRet.metadata, undefined); assert.strictEqual(cellOutputsAddedRet.contentChanges.length, 0); assert.strictEqual(cellOutputsAddedRet.cellChanges.length, 1); - assert.deepStrictEqual(cellOutputsAddedRet.cellChanges[0].cell, editor.document.cellAt(0)); + assert.deepStrictEqual(cellOutputsAddedRet.cellChanges[0].cell, editor.notebook.cellAt(0)); assert.deepStrictEqual(cellOutputsAddedRet.cellChanges[0].executionSummary, { executionOrder: undefined, success: undefined, timing: undefined }); // TODO@jrieken should this be undefined instead all empty? assert.strictEqual(cellOutputsAddedRet.cellChanges[0].document, undefined); assert.strictEqual(cellOutputsAddedRet.cellChanges[0].metadata, undefined); @@ -235,15 +235,15 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('notebook.cell.clearOutputs'); const cellOutputsCleardRet = await cellOutputClear; assert.deepStrictEqual(cellOutputsCleardRet, <vscode.NotebookDocumentChangeEvent>{ - notebook: editor.document, + notebook: editor.notebook, metadata: undefined, contentChanges: [], cellChanges: [{ - cell: editor.document.cellAt(0), + cell: editor.notebook.cellAt(0), document: undefined, executionSummary: undefined, metadata: undefined, - outputs: editor.document.cellAt(0).outputs + outputs: editor.notebook.cellAt(0).outputs }], }); assert.strictEqual(cellOutputsCleardRet.cellChanges[0].cell.outputs.length, 0); @@ -289,21 +289,21 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const editor = await vscode.window.showNotebookDocument(notebook); const notebookChangeEvent = asPromise<vscode.NotebookDocumentChangeEvent>(vscode.workspace.onDidChangeNotebookDocument); - const version = editor.document.version; + const version = editor.notebook.version; await editor.edit(editBuilder => { editBuilder.replaceCells(1, 0, [{ kind: vscode.NotebookCellKind.Code, languageId: 'javascript', value: 'test 2', outputs: [], metadata: undefined }]); editBuilder.replaceCellMetadata(0, { inputCollapsed: false }); }); await notebookChangeEvent; - assert.strictEqual(editor.document.cellCount, 3); - assert.strictEqual(editor.document.cellAt(0)?.metadata.inputCollapsed, false); - assert.strictEqual(version + 1, editor.document.version); + assert.strictEqual(editor.notebook.cellCount, 3); + assert.strictEqual(editor.notebook.cellAt(0)?.metadata.inputCollapsed, false); + assert.strictEqual(version + 1, editor.notebook.version); await vscode.commands.executeCommand('undo'); - assert.strictEqual(version + 2, editor.document.version); - assert.strictEqual(editor.document.cellAt(0)?.metadata.inputCollapsed, undefined); - assert.strictEqual(editor.document.cellCount, 2); + assert.strictEqual(version + 2, editor.notebook.version); + assert.strictEqual(editor.notebook.cellAt(0)?.metadata.inputCollapsed, undefined); + assert.strictEqual(editor.notebook.cellCount, 2); }); // #126371 @@ -326,7 +326,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { assert.strictEqual(getFocusedCell(editor)?.document.getText(), 'test'); assert.strictEqual(getFocusedCell(editor)?.document.languageId, 'typescript'); - const secondCell = editor.document.cellAt(1); + const secondCell = editor.notebook.cellAt(1); assert.strictEqual(secondCell.outputs.length, 1); assert.deepStrictEqual(secondCell.outputs[0].metadata, { testOutputMetadata: true, ['text/plain']: { testOutputItemMetadata: true } }); assert.strictEqual(secondCell.outputs[0].items.length, 1); @@ -353,22 +353,22 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { let activeCell = getFocusedCell(editor); assert.notStrictEqual(getFocusedCell(editor), undefined); assert.strictEqual(activeCell!.document.getText(), ''); - assert.strictEqual(editor.document.cellCount, 4); - assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 1); + assert.strictEqual(editor.notebook.cellCount, 4); + assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 1); // ---- focus bottom ---- // await vscode.commands.executeCommand('notebook.focusBottom'); activeCell = getFocusedCell(editor); - assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 3); + assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 3); // ---- focus top and then copy down ---- // await vscode.commands.executeCommand('notebook.focusTop'); activeCell = getFocusedCell(editor); - assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 0); + assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 0); await vscode.commands.executeCommand('notebook.cell.copyDown'); activeCell = getFocusedCell(editor); - assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 1); + assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 1); assert.strictEqual(activeCell?.document.getText(), 'test'); { @@ -381,25 +381,25 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { } activeCell = getFocusedCell(editor); - assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 1); + assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 1); assert.strictEqual(activeCell?.document.getText(), ''); // ---- focus top and then copy up ---- // await vscode.commands.executeCommand('notebook.focusTop'); await vscode.commands.executeCommand('notebook.cell.copyUp'); - assert.strictEqual(editor.document.cellCount, 5); - assert.strictEqual(editor.document.cellAt(0).document.getText(), 'test'); - assert.strictEqual(editor.document.cellAt(1).document.getText(), 'test'); - assert.strictEqual(editor.document.cellAt(2).document.getText(), ''); - assert.strictEqual(editor.document.cellAt(3).document.getText(), ''); + assert.strictEqual(editor.notebook.cellCount, 5); + assert.strictEqual(editor.notebook.cellAt(0).document.getText(), 'test'); + assert.strictEqual(editor.notebook.cellAt(1).document.getText(), 'test'); + assert.strictEqual(editor.notebook.cellAt(2).document.getText(), ''); + assert.strictEqual(editor.notebook.cellAt(3).document.getText(), ''); activeCell = getFocusedCell(editor); - assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 0); + assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 0); // ---- move up and down ---- // await vscode.commands.executeCommand('notebook.cell.moveDown'); - assert.strictEqual(editor.document.getCells().indexOf(getFocusedCell(editor)!), 1, + assert.strictEqual(editor.notebook.getCells().indexOf(getFocusedCell(editor)!), 1, `first move down, active cell ${getFocusedCell(editor)!.document.uri.toString()}, ${getFocusedCell(editor)!.document.getText()}`); await vscode.commands.executeCommand('workbench.action.files.save'); @@ -427,7 +427,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { // assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first'); // const editor = vscode.window.activeNotebookEditor!; - // const cell = editor.document.cellAt(0); + // const cell = editor.notebook.cellAt(0); // assert.strictEqual(cell.outputs.length, 0); // currentKernelProvider.setHasKernels(false); @@ -452,7 +452,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest'); assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first'); const editor = vscode.window.activeNotebookEditor!; - const cell = editor.document.cellAt(0); + const cell = editor.notebook.cellAt(0); await vscode.commands.executeCommand('notebook.execute'); assert.strictEqual(cell.outputs.length, 0, 'should not execute'); // not runnable, didn't work @@ -463,7 +463,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest'); assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first'); const editor = vscode.window.activeNotebookEditor!; - const cell = editor.document.cellAt(0); + const cell = editor.notebook.cellAt(0); await withEvent(vscode.workspace.onDidChangeNotebookDocument, async (event) => { await vscode.commands.executeCommand('notebook.execute'); @@ -484,7 +484,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('notebook.cell.execute', { start: 0, end: 1 }, resource); await event; assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked - assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath); + assert.strictEqual(vscode.window.activeNotebookEditor?.notebook.uri.fsPath, secondResource.fsPath); }); }); @@ -524,7 +524,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest'); assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true, 'notebook first'); const editor = vscode.window.activeNotebookEditor!; - const cell = editor.document.cellAt(0); + const cell = editor.notebook.cellAt(0); await withEvent<vscode.NotebookDocumentChangeEvent>(vscode.workspace.onDidChangeNotebookDocument, async (event) => { await vscode.commands.executeCommand('notebook.execute'); @@ -544,7 +544,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('notebook.execute', resource); await event; assert.strictEqual(cell.outputs.length, 1, 'should execute'); // runnable, it worked - assert.strictEqual(vscode.window.activeNotebookEditor?.document.uri.fsPath, secondResource.fsPath); + assert.strictEqual(vscode.window.activeNotebookEditor?.notebook.uri.fsPath, secondResource.fsPath); }); }); @@ -553,7 +553,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const editor = await vscode.window.showNotebookDocument(notebook); assert.strictEqual(vscode.window.activeNotebookEditor === editor, true, 'notebook first'); - const cell = editor.document.cellAt(0); + const cell = editor.notebook.cellAt(0); const alternativeKernel = new class extends Kernel { constructor() { @@ -597,7 +597,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const resource = await createRandomNotebookFile(); await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest'); const editor = vscode.window.activeNotebookEditor!; - const cell = editor.document.cellAt(0); + const cell = editor.notebook.cellAt(0); vscode.commands.executeCommand('notebook.cell.execute'); let eventCount = 0; @@ -636,8 +636,8 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const activeCell = getFocusedCell(editor); assert.notStrictEqual(getFocusedCell(editor), undefined); assert.strictEqual(activeCell!.document.getText(), ''); - assert.strictEqual(editor.document.cellCount, 4); - assert.strictEqual(editor.document.getCells().indexOf(activeCell!), 1); + assert.strictEqual(editor.notebook.cellCount, 4); + assert.strictEqual(editor.notebook.getCells().indexOf(activeCell!), 1); await withEvent(vscode.workspace.onDidChangeTextDocument, async event => { const edit = new vscode.WorkspaceEdit(); @@ -645,7 +645,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.workspace.applyEdit(edit); await event; assert.strictEqual(vscode.window.activeNotebookEditor === editor, true); - assert.deepStrictEqual(editor.document.cellAt(1), getFocusedCell(editor)); + assert.deepStrictEqual(editor.notebook.cellAt(1), getFocusedCell(editor)); assert.strictEqual(getFocusedCell(editor)?.document.getText(), 'var abc = 0;'); }); }); @@ -667,8 +667,8 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { // make sure that the previous dirty editor is still restored in the extension host and no data loss assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true); - assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cellAt(1), getFocusedCell(vscode.window.activeNotebookEditor)); - assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cellCount, 4); + assert.deepStrictEqual(vscode.window.activeNotebookEditor?.notebook.cellAt(1), getFocusedCell(vscode.window.activeNotebookEditor)); + assert.deepStrictEqual(vscode.window.activeNotebookEditor?.notebook.cellCount, 4); assert.strictEqual(getFocusedCell(vscode.window.activeNotebookEditor)?.document.getText(), 'var abc = 0;'); }); @@ -692,15 +692,15 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { // switch to the first editor await vscode.window.showNotebookDocument(notebook); assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true); - assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cellAt(1), getFocusedCell(vscode.window.activeNotebookEditor)); - assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cellCount, 4); + assert.deepStrictEqual(vscode.window.activeNotebookEditor?.notebook.cellAt(1), getFocusedCell(vscode.window.activeNotebookEditor)); + assert.deepStrictEqual(vscode.window.activeNotebookEditor?.notebook.cellCount, 4); assert.strictEqual(getFocusedCell(vscode.window.activeNotebookEditor)?.document.getText(), 'var abc = 0;'); // switch to the second editor await vscode.window.showNotebookDocument(secondNotebook); assert.strictEqual(vscode.window.activeNotebookEditor !== undefined, true); - assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cellAt(1), getFocusedCell(vscode.window.activeNotebookEditor)); - assert.deepStrictEqual(vscode.window.activeNotebookEditor?.document.cellCount, 3); + assert.deepStrictEqual(vscode.window.activeNotebookEditor?.notebook.cellAt(1), getFocusedCell(vscode.window.activeNotebookEditor)); + assert.deepStrictEqual(vscode.window.activeNotebookEditor?.notebook.cellCount, 3); assert.strictEqual(getFocusedCell(vscode.window.activeNotebookEditor)?.document.getText(), ''); }); @@ -721,7 +721,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { assert.strictEqual(getFocusedCell(vscode.window.activeNotebookEditor!)?.document.languageId, 'typescript'); assert.notStrictEqual(firstNotebookEditor, secondNotebookEditor); - assert.strictEqual(firstNotebookEditor?.document, secondNotebookEditor?.document, 'split notebook editors share the same document'); + assert.strictEqual(firstNotebookEditor?.notebook, secondNotebookEditor?.notebook, 'split notebook editors share the same document'); }); @@ -737,7 +737,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { // await vscode.commands.executeCommand('vscode.open', cell.document.uri, vscode.ViewColumn.Active); assert.strictEqual(!!vscode.window.activeNotebookEditor, true); - assert.strictEqual(vscode.window.activeNotebookEditor!.document.uri.toString(), document.uri.toString()); + assert.strictEqual(vscode.window.activeNotebookEditor!.notebook.uri.toString(), document.uri.toString()); }); test('Cannot open notebook from cell-uri with vscode.open-command', async function () { @@ -752,7 +752,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { // removes the fragment if it matches something numeric. For notebooks that's not wanted... await vscode.commands.executeCommand('vscode.open', cell.document.uri); - assert.strictEqual(vscode.window.activeNotebookEditor!.document.uri.toString(), document.uri.toString()); + assert.strictEqual(vscode.window.activeNotebookEditor!.notebook.uri.toString(), document.uri.toString()); }); test('#97830, #97764. Support switch to other editor types', async function () { @@ -805,15 +805,15 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { await vscode.commands.executeCommand('notebook.cell.copyDown'); await vscode.commands.executeCommand('notebook.cell.edit'); activeCell = getFocusedCell(vscode.window.activeNotebookEditor); - assert.strictEqual(vscode.window.activeNotebookEditor!.document.getCells().indexOf(activeCell!), 1); + assert.strictEqual(vscode.window.activeNotebookEditor!.notebook.getCells().indexOf(activeCell!), 1); assert.strictEqual(activeCell?.document.getText(), 'test'); const edit = new vscode.WorkspaceEdit(); edit.insert(getFocusedCell(vscode.window.activeNotebookEditor)!.document.uri, new vscode.Position(0, 0), 'var abc = 0;'); await vscode.workspace.applyEdit(edit); - assert.strictEqual(vscode.window.activeNotebookEditor!.document.getCells().length, 3); - assert.notStrictEqual(vscode.window.activeNotebookEditor!.document.cellAt(0).document.getText(), vscode.window.activeNotebookEditor!.document.cellAt(1).document.getText()); + assert.strictEqual(vscode.window.activeNotebookEditor!.notebook.getCells().length, 3); + assert.notStrictEqual(vscode.window.activeNotebookEditor!.notebook.cellAt(0).document.getText(), vscode.window.activeNotebookEditor!.notebook.cellAt(1).document.getText()); await closeAllEditors(); }); @@ -876,7 +876,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const resource = await createRandomNotebookFile(); await vscode.commands.executeCommand('vscode.openWith', resource, 'notebookCoreTest'); const editor = vscode.window.activeNotebookEditor!; - const cell = editor.document.cellAt(0); + const cell = editor.notebook.cellAt(0); assert.strictEqual(cell.executionSummary?.success, undefined); assert.strictEqual(cell.executionSummary?.executionOrder, undefined); @@ -999,7 +999,7 @@ const apiTestContentProvider: vscode.NotebookContentProvider = { const notebook = await openRandomNotebookDocument(); const editor = await vscode.window.showNotebookDocument(notebook); - assert.strictEqual(editor.document.metadata.custom?.testMetadata, false); + assert.strictEqual(editor.notebook.metadata.custom?.testMetadata, false); assert.strictEqual(getFocusedCell(editor)?.metadata.custom?.testCellMetadata, 123); assert.strictEqual(getFocusedCell(editor)?.document.languageId, 'typescript'); }); |