Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/client/jupyter/languageserver/notebookConcatDocument.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import { NotebookConcatTextDocument, NotebookCell, NotebookDocument } from 'vsco
import { IVSCodeNotebook } from '../../common/application/types';
import { IDisposable } from '../../common/types';
import { PYTHON_LANGUAGE } from '../../common/constants';
import { SafeNotebookDocument } from './safeNotebookDocument';

const NotebookConcatPrefix = '_NotebookConcat_';

/**
* This helper class is used to present a converted document to an LS
*/
export class NotebookConcatDocument implements TextDocument, IDisposable {
public get notebook(): SafeNotebookDocument {
public get notebook(): NotebookDocument {
return this._notebook;
}

Expand Down Expand Up @@ -118,14 +117,14 @@ export class NotebookConcatDocument implements TextDocument, IDisposable {

private onCellsChangedEmitter = new EventEmitter<TextDocumentChangeEvent>();

private _notebook: SafeNotebookDocument;
private _notebook: NotebookDocument;

constructor(notebook: NotebookDocument, notebookApi: IVSCodeNotebook, selector: DocumentSelector) {
const dir = path.dirname(notebook.uri.fsPath);
// Create a safe notebook document so that we can handle both >= 1.56 vscode API and < 1.56
// when vscode stable is 1.56 and both Python release and insiders can update to that engine version we
// can remove this and just use NotebookDocument directly
this._notebook = new SafeNotebookDocument(notebook);
this._notebook = notebook;
// Note: Has to be different than the prefix for old notebook editor (HiddenFileFormat) so
// that the caller doesn't remove diagnostics for this document.
this.dummyFilePath = path.join(dir, `${NotebookConcatPrefix}${uuid().replace(/-/g, '')}.py`);
Expand Down
13 changes: 5 additions & 8 deletions src/client/jupyter/languageserver/notebookConverter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import { NotebookCell, NotebookConcatTextDocument, NotebookDocument } from 'vsco
import { IVSCodeNotebook } from '../../common/application/types';
import { IFileSystem } from '../../common/platform/types';
import { NotebookConcatDocument } from './notebookConcatDocument';
import { SafeNotebookDocument } from './safeNotebookDocument';

/* Used by code actions. Disabled for now.
function toRange(rangeLike: Range): Range {
Expand Down Expand Up @@ -649,17 +648,15 @@ export class NotebookConverter implements Disposable {
}

private onDidOpenNotebook(doc: NotebookDocument) {
const safeDoc = new SafeNotebookDocument(doc);
if (this.notebookFilter.test(safeDoc.fileName)) {
this.getTextDocumentWrapper(safeDoc.uri);
if (this.notebookFilter.test(doc.uri.fsPath)) {
this.getTextDocumentWrapper(doc.uri);
}
}

private onDidCloseNotebook(doc: NotebookDocument) {
const safeDoc = new SafeNotebookDocument(doc);
if (this.notebookFilter.test(safeDoc.fileName)) {
const key = NotebookConverter.getDocumentKey(safeDoc.uri);
const wrapper = this.getTextDocumentWrapper(safeDoc.uri);
if (this.notebookFilter.test(doc.uri.fsPath)) {
const key = NotebookConverter.getDocumentKey(doc.uri);
const wrapper = this.getTextDocumentWrapper(doc.uri);
this.activeDocuments.delete(key);
this.activeDocumentsOutgoingMap.delete(NotebookConverter.getDocumentKey(wrapper.uri));
}
Expand Down
91 changes: 0 additions & 91 deletions src/client/jupyter/languageserver/safeNotebookDocument.ts

This file was deleted.