MCPcopy Create free account
hub / github.com/Exafunction/codeium-chrome / constructor

Method constructor

src/jupyterlabPlugin.ts:28–74  ·  view source on GitHub ↗
(
    readonly extensionId: string,
    app: JupyterFrontEnd,
    notebookTracker: INotebookTracker,
    editorTracker: IEditorTracker,
    documentManager: IDocumentManager,
    codeMirror: ICodeMirror
  )

Source from the content-addressed store, hash-verified

26 codeMirrorManager: CodeMirrorManager;
27
28 constructor(
29 readonly extensionId: string,
30 app: JupyterFrontEnd,
31 notebookTracker: INotebookTracker,
32 editorTracker: IEditorTracker,
33 documentManager: IDocumentManager,
34 codeMirror: ICodeMirror
35 ) {
36 this.app = app;
37 this.notebookTracker = notebookTracker;
38 this.editorTracker = editorTracker;
39 this.documentManager = documentManager;
40 this.codeMirrorManager = new CodeMirrorManager(extensionId, {
41 ideName: 'jupyterlab',
42 ideVersion: `${app.name.toLowerCase()} ${app.version}`,
43 });
44 addListeners(codeMirror.CodeMirror, this.codeMirrorManager);
45 // The keyboard shortcuts for these commands are added and removed depending
46 // on the presence of ghost text, since they cannot defer to a shortcut on a
47 // parent element.
48 app.commands.addCommand(COMMAND_ACCEPT, {
49 execute: () => {
50 this.codeMirrorManager.acceptCompletion();
51 },
52 });
53 app.commands.addCommand(COMMAND_DISMISS, {
54 execute: () => {
55 this.codeMirrorManager.clearCompletion('user dismissed');
56 },
57 });
58 const keyboardHandler = this.keydownHandler.bind(this);
59 // There is no cellAdded listener, so resort to maintaining a single
60 // listener for all cells.
61 notebookTracker.activeCellChanged.connect((_notebookTracker, cell) => {
62 this.previousCellHandler?.dispose();
63 this.previousCellHandler = undefined;
64 if (cell === null) {
65 return;
66 }
67 this.previousCellHandler = cell.editor.addKeydownHandler(keyboardHandler);
68 }, this);
69 editorTracker.widgetAdded.connect((_editorTracker, widget) => {
70 widget.content.editor.addKeydownHandler(keyboardHandler);
71 this.nonNotebookWidget.add(widget.id);
72 widget.disposed.connect(this.removeNonNotebookWidget, this);
73 }, this);
74 }
75
76 removeNonNotebookWidget(w: Widget) {
77 this.nonNotebookWidget.delete(w.id);

Callers

nothing calls this directly

Calls 3

addListenersFunction · 0.90
acceptCompletionMethod · 0.80
clearCompletionMethod · 0.45

Tested by

no test coverage detected