Skip to content

Commit 2d89982

Browse files
committed
bigger native repl suggestion link on terminal
1 parent 4322684 commit 2d89982

File tree

2 files changed

+41
-6
lines changed

2 files changed

+41
-6
lines changed

src/client/terminals/pythonStartupLinkProvider.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ export class CustomTerminalLinkProvider implements TerminalLinkProvider<CustomTe
2121
_token: CancellationToken,
2222
): ProviderResult<CustomTerminalLink[]> {
2323
const links: CustomTerminalLink[] = [];
24-
const expectedNativeLink = 'VS Code Native REPL';
24+
let expectedNativeLink;
25+
26+
if (process.platform === 'darwin') {
27+
expectedNativeLink = 'Cmd click to launch VS Code Native REPL';
28+
} else {
29+
expectedNativeLink = 'Ctrl click to launch VS Code Native REPL';
30+
}
2531

2632
if (context.line.includes(expectedNativeLink)) {
2733
links.push({

src/test/terminals/shellIntegration/pythonStartup.test.ts

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,10 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => {
147147
registerTerminalLinkProviderStub.restore();
148148
});
149149

150-
test('Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => {
150+
test('Mac - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => {
151151
const provider = new CustomTerminalLinkProvider();
152152
const context: TerminalLinkContext = {
153-
line: 'Some random string with VS Code Native REPL in it',
153+
line: 'Some random string with Cmd click to launch VS Code Native REPL',
154154
terminal: {} as Terminal,
155155
};
156156
const token: CancellationToken = {
@@ -168,10 +168,39 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => {
168168
assert.equal(links[0].command, 'python.startNativeREPL', 'Expected command to be python.startNativeREPL');
169169
assert.equal(
170170
links[0].startIndex,
171-
context.line.indexOf('VS Code Native REPL'),
172-
'Expected startIndex to be 0',
171+
context.line.indexOf('Cmd click to launch VS Code Native REPL'),
172+
'start index should match',
173173
);
174-
assert.equal(links[0].length, 'VS Code Native REPL'.length, 'Expected length to be 16');
174+
assert.equal(links[0].length, 'Cmd click to launch VS Code Native REPL'.length, 'Match expected length');
175+
assert.equal(links[0].tooltip, Repl.launchNativeRepl, 'Expected tooltip to be Launch VS Code Native REPL');
176+
}
177+
});
178+
179+
test('Windows/Linux - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => {
180+
const provider = new CustomTerminalLinkProvider();
181+
const context: TerminalLinkContext = {
182+
line: 'Some random string with Ctrl click to launch VS Code Native REPL',
183+
terminal: {} as Terminal,
184+
};
185+
const token: CancellationToken = {
186+
isCancellationRequested: false,
187+
onCancellationRequested: new EventEmitter<unknown>().event,
188+
};
189+
190+
const links = provider.provideTerminalLinks(context, token);
191+
192+
assert.isNotNull(links, 'Expected links to be not undefined');
193+
assert.isArray(links, 'Expected links to be an array');
194+
assert.isNotEmpty(links, 'Expected links to be not empty');
195+
196+
if (Array.isArray(links)) {
197+
assert.equal(links[0].command, 'python.startNativeREPL', 'Expected command to be python.startNativeREPL');
198+
assert.equal(
199+
links[0].startIndex,
200+
context.line.indexOf('Ctrl click to launch VS Code Native REPL'),
201+
'start index should match',
202+
);
203+
assert.equal(links[0].length, 'Ctrl click to launch VS Code Native REPL'.length, 'Match expected Length');
175204
assert.equal(links[0].tooltip, Repl.launchNativeRepl, 'Expected tooltip to be Launch VS Code Native REPL');
176205
}
177206
});

0 commit comments

Comments
 (0)