@krassowski/jupyterlab_go_to_definition
Version:
Jump to definition of a variable or function in JupyterLab
20 lines (15 loc) • 476 B
text/typescript
import { ITokensProvider } from '../editor';
import { CodeMirrorEditor } from '@jupyterlab/codemirror';
export class CodeMirrorTokensProvider implements ITokensProvider {
editor: CodeMirrorEditor;
constructor(editor: CodeMirrorEditor) {
this.editor = editor;
}
getTokens() {
return this.editor.getTokens();
}
getTokenAt(offset: number) {
let position = this.editor.getPositionAt(offset);
return this.editor.getTokenForPosition(position);
}
}