Skip to content

Commit f9093d8

Browse files
committed
Take feedback
1 parent cb63ae7 commit f9093d8

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

python_files/pythonrc.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,5 @@ def __str__(self):
7878
if sys.platform != "win32" and (not is_wsl) and use_shell_integration:
7979
sys.ps1 = PS1()
8080
# TODO: Word this better - get feedback
81-
print("this is link to launch native repl")
81+
# TODO: add ctrl/cmd depending on OS
82+
print("Click to launch VS Code Native REPL")

src/client/extensionActivation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export function activateFeatures(ext: ExtensionState, _components: Components):
116116
registerStartNativeReplCommand(ext.disposables, interpreterService);
117117
registerReplCommands(ext.disposables, interpreterService, executionHelper, commandManager);
118118
registerReplExecuteOnEnter(ext.disposables, interpreterService, commandManager);
119-
registerCustomTerminalLinkProvider(ext.context); // TODO: Is there way to avoid passing in ext.context?
119+
registerCustomTerminalLinkProvider(ext.disposables);
120120
}
121121

122122
/// //////////////////////////
Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,36 @@
11
/* eslint-disable class-methods-use-this */
2-
import * as vscode from 'vscode';
2+
import {
3+
CancellationToken,
4+
Disposable,
5+
ProviderResult,
6+
TerminalLink,
7+
TerminalLinkContext,
8+
TerminalLinkProvider,
9+
l10n,
10+
} from 'vscode';
311
import { executeCommand } from '../common/vscodeApis/commandApis';
4-
import { IExtensionContext } from '../common/types';
512
import { registerTerminalLinkProvider } from '../common/vscodeApis/windowApis';
613

7-
interface CustomTerminalLink extends vscode.TerminalLink {
14+
interface CustomTerminalLink extends TerminalLink {
815
command: string;
916
}
1017

11-
export class CustomTerminalLinkProvider implements vscode.TerminalLinkProvider<CustomTerminalLink> {
12-
// TODO: How should I properly add this to disposables?
13-
// Need advice, do not want to cause memory leak.
14-
15-
// private disposable: Disposable;
16-
17-
// constructor() {
18-
// this.disposable = window.registerTerminalLinkProvider(this);
19-
// }
20-
21-
// dispose(): void {
22-
// this.disposable.dispose();
23-
// }
24-
18+
export class CustomTerminalLinkProvider implements TerminalLinkProvider<CustomTerminalLink> {
2519
provideTerminalLinks(
26-
context: vscode.TerminalLinkContext,
27-
_token: vscode.CancellationToken,
28-
): vscode.ProviderResult<CustomTerminalLink[]> {
20+
context: TerminalLinkContext,
21+
_token: CancellationToken,
22+
): ProviderResult<CustomTerminalLink[]> {
2923
const links: CustomTerminalLink[] = [];
3024
// Question: What if context.line is truncated because of user zoom setting?
3125
// Meaning what if this line is separated into two+ line in terminal?
32-
const expectedNativeLink = 'this is link to launch native repl';
26+
const expectedNativeLink = 'VS Code Native REPL';
3327

3428
// eslint-disable-next-line no-cond-assign
35-
if (context.line === expectedNativeLink) {
29+
if (context.line.includes(expectedNativeLink)) {
3630
links.push({
37-
startIndex: 0,
31+
startIndex: context.line.indexOf(expectedNativeLink),
3832
length: expectedNativeLink.length,
39-
tooltip: 'Launch Native REPL',
33+
tooltip: l10n.t('Launch VS Code Native REPL'),
4034
command: 'python.startNativeREPL',
4135
});
4236
}
@@ -48,7 +42,6 @@ export class CustomTerminalLinkProvider implements vscode.TerminalLinkProvider<C
4842
}
4943
}
5044

51-
export function registerCustomTerminalLinkProvider(extensionContext: IExtensionContext): void {
52-
const provider = new CustomTerminalLinkProvider();
53-
extensionContext.subscriptions.push(registerTerminalLinkProvider(provider));
45+
export function registerCustomTerminalLinkProvider(disposables: Disposable[]): void {
46+
disposables.push(registerTerminalLinkProvider(new CustomTerminalLinkProvider()));
5447
}

0 commit comments

Comments
 (0)