mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-27 19:08:21 +01:00
@@ -17,7 +17,7 @@ import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'
|
||||
import { FileSystemProviderErrorCode, markAsFileSystemProviderError } from 'vs/platform/files/common/files';
|
||||
import { RemoteAuthorityResolverErrorCode } from 'vs/platform/remote/common/remoteAuthorityResolver';
|
||||
import { IRelativePatternDto } from 'vs/workbench/api/common/extHost.protocol';
|
||||
import { CellEditType, ICellPartialMetadataEdit, IDocumentMetadataEdit, isTextStreamMime } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { CellEditType, CellUri, ICellPartialMetadataEdit, IDocumentMetadataEdit, isTextStreamMime } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
import { checkProposedApiEnabled } from 'vs/workbench/services/extensions/common/extensions';
|
||||
import type * as vscode from 'vscode';
|
||||
|
||||
@@ -862,6 +862,10 @@ export class WorkspaceEdit implements vscode.WorkspaceEdit {
|
||||
edit = editOrTuple;
|
||||
}
|
||||
if (NotebookEdit.isNotebookCellEdit(edit)) {
|
||||
if (uri.scheme === CellUri.scheme) {
|
||||
throw new Error('set must be called with a notebook document URI, not a cell URI.');
|
||||
}
|
||||
|
||||
if (edit.newCellMetadata) {
|
||||
this.replaceNotebookCellMetadata(uri, edit.range.start, edit.newCellMetadata, metadata);
|
||||
} else if (edit.newNotebookMetadata) {
|
||||
|
||||
@@ -4,13 +4,14 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import * as assert from 'assert';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as types from 'vs/workbench/api/common/extHostTypes';
|
||||
import { CancellationError } from 'vs/base/common/errors';
|
||||
import { MarshalledId } from 'vs/base/common/marshallingIds';
|
||||
import { Mimes } from 'vs/base/common/mime';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
import { assertType } from 'vs/base/common/types';
|
||||
import { Mimes } from 'vs/base/common/mime';
|
||||
import { MarshalledId } from 'vs/base/common/marshallingIds';
|
||||
import { CancellationError } from 'vs/base/common/errors';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as types from 'vs/workbench/api/common/extHostTypes';
|
||||
import { CellUri } from 'vs/workbench/contrib/notebook/common/notebookCommon';
|
||||
|
||||
function assertToJSON(a: any, expected: any) {
|
||||
const raw = JSON.stringify(a);
|
||||
@@ -432,6 +433,23 @@ suite('ExtHostTypes', function () {
|
||||
assert.strictEqual(second.edit.newText, 'Foo');
|
||||
});
|
||||
|
||||
test('WorkspaceEdit - NotebookEdits', () => {
|
||||
const edit = new types.WorkspaceEdit();
|
||||
const notebookEdit = types.NotebookEdit.insertCells(0, [new types.NotebookCellData(types.NotebookCellKind.Code, '// hello', 'javascript')]) as types.NotebookEdit;
|
||||
const notebookUri = URI.parse('/foo/notebook.ipynb');
|
||||
edit.set(notebookUri, [notebookEdit]);
|
||||
|
||||
const cellUri = CellUri.generate(notebookUri, 123);
|
||||
try {
|
||||
edit.set(cellUri, [notebookEdit]);
|
||||
} catch (err) {
|
||||
assert.ok(err.message.includes('set must be called with a notebook document URI'), err.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error('Expected set to throw with cell URI');
|
||||
});
|
||||
|
||||
test('DocumentLink', () => {
|
||||
assert.throws(() => new types.DocumentLink(null!, null!));
|
||||
assert.throws(() => new types.DocumentLink(new types.Range(1, 1, 1, 1), null!));
|
||||
|
||||
Reference in New Issue
Block a user