Skip to content

Commit 70352bb

Browse files
committed
Fix jumping in files (correctly infer the current widget id)
1 parent 5a01ef9 commit 70352bb

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

packages/jupyterlab-lsp/src/features/jump_to.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { IEditorTracker } from '@jupyterlab/fileeditor';
1919
import { CodeMirrorEditor } from '@jupyterlab/codemirror';
2020
import { INotebookTracker } from '@jupyterlab/notebook';
2121
import { IDocumentManager } from '@jupyterlab/docmanager';
22-
import { ILSPFeatureManager, PLUGIN_ID } from '../tokens';
22+
import { ILSPAdapterManager, ILSPFeatureManager, PLUGIN_ID } from '../tokens';
2323
import { LabIcon } from '@jupyterlab/ui-components';
2424
import jumpToSvg from '../../style/icons/jump-to.svg';
2525

@@ -102,7 +102,6 @@ export class CMJumpToDefinition extends CodeMirrorIntegration {
102102
// otherwise there is no virtual document and we expect the returned position to be source position:
103103
let source_position_ce = PositionConverter.cm_to_ce(virtual_position);
104104
console.log(`Jumping to external file: ${uri}`);
105-
106105
console.log('Jump target (source location):', source_position_ce);
107106

108107
// can it be resolved vs our guessed server root?
@@ -143,19 +142,18 @@ export class CMJumpToDefinition extends CodeMirrorIntegration {
143142
}
144143

145144
class JumperLabIntegration implements IFeatureLabIntegration {
146-
private fileEditorTracker: IEditorTracker;
147-
private notebookTracker: INotebookTracker;
145+
private adapterManager: ILSPAdapterManager;
148146
private jumpers: Map<string, CodeJumper>;
149147
// settings should be implemented in the future
150148
settings?: FeatureSettings<any>;
151149

152150
constructor(
151+
adapterManager: ILSPAdapterManager,
153152
fileEditorTracker: IEditorTracker,
154153
notebookTracker: INotebookTracker,
155154
documentManager: IDocumentManager
156155
) {
157-
this.fileEditorTracker = fileEditorTracker;
158-
this.notebookTracker = notebookTracker;
156+
this.adapterManager = adapterManager;
159157
this.jumpers = new Map();
160158

161159
fileEditorTracker.widgetAdded.connect((sender, widget) => {
@@ -175,9 +173,7 @@ class JumperLabIntegration implements IFeatureLabIntegration {
175173
}
176174

177175
get jumper(): CodeJumper {
178-
let current =
179-
this.notebookTracker.currentWidget.id ||
180-
this.fileEditorTracker.currentWidget.id;
176+
let current = this.adapterManager.currentAdapter.widget.id;
181177
return this.jumpers.get(current);
182178
}
183179
}
@@ -204,6 +200,7 @@ export const JUMP_PLUGIN: JupyterFrontEndPlugin<void> = {
204200
id: FEATURE_ID,
205201
requires: [
206202
ILSPFeatureManager,
203+
ILSPAdapterManager,
207204
IEditorTracker,
208205
INotebookTracker,
209206
IDocumentManager
@@ -212,11 +209,13 @@ export const JUMP_PLUGIN: JupyterFrontEndPlugin<void> = {
212209
activate: (
213210
app: JupyterFrontEnd,
214211
featureManager: ILSPFeatureManager,
212+
adapterManager: ILSPAdapterManager,
215213
fileEditorTracker: IEditorTracker,
216214
notebookTracker: INotebookTracker,
217215
documentManager: IDocumentManager
218216
) => {
219217
let labIntegration = new JumperLabIntegration(
218+
adapterManager,
220219
fileEditorTracker,
221220
notebookTracker,
222221
documentManager

0 commit comments

Comments
 (0)