Skip to content

Commit 62cc728

Browse files
committed
Remove CodeMirror import in Virtual document, expose the foreign documents map
1 parent ca4e4b3 commit 62cc728

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

packages/jupyterlab-lsp/src/virtual/document.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import { IOverridesRegistry } from '../magics/overrides';
77
import { DefaultMap, until_ready } from '../utils';
88
import { Signal } from '@lumino/signaling';
99
import { CodeEditor } from '@jupyterlab/codeeditor';
10-
import * as CodeMirror from 'codemirror';
1110
import {
1211
IEditorPosition,
1312
ISourcePosition,
@@ -41,6 +40,8 @@ export interface IVirtualDocumentBlock {
4140
virtual_document: VirtualDocument;
4241
}
4342

43+
export type ForeignDocumentsMap = Map<IRange, IVirtualDocumentBlock>;
44+
4445
interface ISourceLine {
4546
virtual_line: number;
4647
editor: CodeEditor.IEditor;
@@ -50,7 +51,7 @@ interface ISourceLine {
5051
/**
5152
* Everything which is not in the range of foreign documents belongs to the host.
5253
*/
53-
foreign_documents_map: Map<IRange, IVirtualDocumentBlock>;
54+
foreign_documents_map: ForeignDocumentsMap;
5455
}
5556

5657
export interface IForeignContext {
@@ -580,6 +581,14 @@ export class VirtualDocument {
580581
return { lines, foreign_document_map, skip_inspect };
581582
}
582583

584+
get foreign_document_maps(): ForeignDocumentsMap[] {
585+
let maps = new Set<ForeignDocumentsMap>();
586+
for (let line of this.source_lines.values()) {
587+
maps.add(line.foreign_documents_map);
588+
}
589+
return [...maps.values()];
590+
}
591+
583592
append_code_block(
584593
cell_code: string,
585594
ce_editor: CodeEditor.IEditor,
@@ -753,7 +762,7 @@ export class VirtualDocument {
753762
return this.virtual_lines.get(line).editor;
754763
}
755764

756-
get_editor_at_source_line(pos: CodeMirror.Position): CodeEditor.IEditor {
765+
get_editor_at_source_line(pos: ISourcePosition): CodeEditor.IEditor {
757766
return this.source_lines.get(pos.line).editor;
758767
}
759768

0 commit comments

Comments
 (0)