Skip to content

Commit

Permalink
Allow to select the path in debugger source component (#16246)
Browse files Browse the repository at this point in the history
Co-authored-by: Jeremy Tuloup <jeremy.tuloup@gmail.com>
  • Loading branch information
krassowski and jtpio committed May 14, 2024
1 parent 82f0327 commit ce9976b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/debugger/src/panels/sources/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class Sources extends PanelWithToolbar {
})
);
const sourcePath = ReactWidget.create(
<SourcePathComponent model={model} />
<SourcePathComponent model={model} trans={trans} />
);

this.toolbar.addItem('sourcePath', sourcePath);
Expand Down
12 changes: 10 additions & 2 deletions packages/debugger/src/panels/sources/sourcepath.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Distributed under the terms of the Modified BSD License.

import { UseSignal } from '@jupyterlab/ui-components';
import { TranslationBundle } from '@jupyterlab/translation';
import React from 'react';
import { IDebugger } from '../../tokens';

Expand All @@ -12,15 +13,22 @@ import { IDebugger } from '../../tokens';
* @param props.model The model for the sources.
*/
export const SourcePathComponent = ({
model
model,
trans
}: {
model: IDebugger.Model.ISources;
trans: TranslationBundle;
}): JSX.Element => {
return (
<UseSignal signal={model.currentSourceChanged} initialSender={model}>
{(model): JSX.Element => (
<span
onClick={(): void => model?.open()}
onClick={(event): void => {
if (event.ctrlKey) {
model?.open();
}
}}
title={trans.__('Ctrl + click to open in the Main Area')}
className="jp-DebuggerSources-header-path"
>
{model?.currentSource?.path ?? ''}
Expand Down
1 change: 1 addition & 0 deletions packages/debugger/style/sources.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@
white-space: nowrap;
font-size: var(--jp-ui-font-size0);
color: var(--jp-ui-font-color1);
user-select: text;
}

0 comments on commit ce9976b

Please sign in to comment.