From 2d89982a1cd29cf8286094a3a33a6b9c5a7dad1e Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Mon, 27 Jan 2025 16:02:25 -0800 Subject: [PATCH 1/2] bigger native repl suggestion link on terminal --- .../terminals/pythonStartupLinkProvider.ts | 8 +++- .../shellIntegration/pythonStartup.test.ts | 39 ++++++++++++++++--- 2 files changed, 41 insertions(+), 6 deletions(-) diff --git a/src/client/terminals/pythonStartupLinkProvider.ts b/src/client/terminals/pythonStartupLinkProvider.ts index 00dcbfd757aa..aba1270f1412 100644 --- a/src/client/terminals/pythonStartupLinkProvider.ts +++ b/src/client/terminals/pythonStartupLinkProvider.ts @@ -21,7 +21,13 @@ export class CustomTerminalLinkProvider implements TerminalLinkProvider { const links: CustomTerminalLink[] = []; - const expectedNativeLink = 'VS Code Native REPL'; + let expectedNativeLink; + + if (process.platform === 'darwin') { + expectedNativeLink = 'Cmd click to launch VS Code Native REPL'; + } else { + expectedNativeLink = 'Ctrl click to launch VS Code Native REPL'; + } if (context.line.includes(expectedNativeLink)) { links.push({ diff --git a/src/test/terminals/shellIntegration/pythonStartup.test.ts b/src/test/terminals/shellIntegration/pythonStartup.test.ts index af90a1886bb5..c373e5b5e640 100644 --- a/src/test/terminals/shellIntegration/pythonStartup.test.ts +++ b/src/test/terminals/shellIntegration/pythonStartup.test.ts @@ -147,10 +147,10 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => { registerTerminalLinkProviderStub.restore(); }); - test('Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => { + test('Mac - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => { const provider = new CustomTerminalLinkProvider(); const context: TerminalLinkContext = { - line: 'Some random string with VS Code Native REPL in it', + line: 'Some random string with Cmd click to launch VS Code Native REPL', terminal: {} as Terminal, }; const token: CancellationToken = { @@ -168,10 +168,39 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => { assert.equal(links[0].command, 'python.startNativeREPL', 'Expected command to be python.startNativeREPL'); assert.equal( links[0].startIndex, - context.line.indexOf('VS Code Native REPL'), - 'Expected startIndex to be 0', + context.line.indexOf('Cmd click to launch VS Code Native REPL'), + 'start index should match', ); - assert.equal(links[0].length, 'VS Code Native REPL'.length, 'Expected length to be 16'); + assert.equal(links[0].length, 'Cmd click to launch VS Code Native REPL'.length, 'Match expected length'); + assert.equal(links[0].tooltip, Repl.launchNativeRepl, 'Expected tooltip to be Launch VS Code Native REPL'); + } + }); + + test('Windows/Linux - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => { + const provider = new CustomTerminalLinkProvider(); + const context: TerminalLinkContext = { + line: 'Some random string with Ctrl click to launch VS Code Native REPL', + terminal: {} as Terminal, + }; + const token: CancellationToken = { + isCancellationRequested: false, + onCancellationRequested: new EventEmitter().event, + }; + + const links = provider.provideTerminalLinks(context, token); + + assert.isNotNull(links, 'Expected links to be not undefined'); + assert.isArray(links, 'Expected links to be an array'); + assert.isNotEmpty(links, 'Expected links to be not empty'); + + if (Array.isArray(links)) { + assert.equal(links[0].command, 'python.startNativeREPL', 'Expected command to be python.startNativeREPL'); + assert.equal( + links[0].startIndex, + context.line.indexOf('Ctrl click to launch VS Code Native REPL'), + 'start index should match', + ); + assert.equal(links[0].length, 'Ctrl click to launch VS Code Native REPL'.length, 'Match expected Length'); assert.equal(links[0].tooltip, Repl.launchNativeRepl, 'Expected tooltip to be Launch VS Code Native REPL'); } }); From bfc3e5525d285fe180c3092aa66130ab02ee1bac Mon Sep 17 00:00:00 2001 From: Anthony Kim Date: Mon, 27 Jan 2025 16:07:56 -0800 Subject: [PATCH 2/2] tests --- .../shellIntegration/pythonStartup.test.ts | 142 +++++++++++------- 1 file changed, 84 insertions(+), 58 deletions(-) diff --git a/src/test/terminals/shellIntegration/pythonStartup.test.ts b/src/test/terminals/shellIntegration/pythonStartup.test.ts index c373e5b5e640..06364c9445aa 100644 --- a/src/test/terminals/shellIntegration/pythonStartup.test.ts +++ b/src/test/terminals/shellIntegration/pythonStartup.test.ts @@ -146,64 +146,90 @@ suite('Terminal - Shell Integration with PYTHONSTARTUP', () => { registerTerminalLinkProviderStub.restore(); }); - - test('Mac - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => { - const provider = new CustomTerminalLinkProvider(); - const context: TerminalLinkContext = { - line: 'Some random string with Cmd click to launch VS Code Native REPL', - terminal: {} as Terminal, - }; - const token: CancellationToken = { - isCancellationRequested: false, - onCancellationRequested: new EventEmitter().event, - }; - - const links = provider.provideTerminalLinks(context, token); - - assert.isNotNull(links, 'Expected links to be not undefined'); - assert.isArray(links, 'Expected links to be an array'); - assert.isNotEmpty(links, 'Expected links to be not empty'); - - if (Array.isArray(links)) { - assert.equal(links[0].command, 'python.startNativeREPL', 'Expected command to be python.startNativeREPL'); - assert.equal( - links[0].startIndex, - context.line.indexOf('Cmd click to launch VS Code Native REPL'), - 'start index should match', - ); - assert.equal(links[0].length, 'Cmd click to launch VS Code Native REPL'.length, 'Match expected length'); - assert.equal(links[0].tooltip, Repl.launchNativeRepl, 'Expected tooltip to be Launch VS Code Native REPL'); - } - }); - - test('Windows/Linux - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => { - const provider = new CustomTerminalLinkProvider(); - const context: TerminalLinkContext = { - line: 'Some random string with Ctrl click to launch VS Code Native REPL', - terminal: {} as Terminal, - }; - const token: CancellationToken = { - isCancellationRequested: false, - onCancellationRequested: new EventEmitter().event, - }; - - const links = provider.provideTerminalLinks(context, token); - - assert.isNotNull(links, 'Expected links to be not undefined'); - assert.isArray(links, 'Expected links to be an array'); - assert.isNotEmpty(links, 'Expected links to be not empty'); - - if (Array.isArray(links)) { - assert.equal(links[0].command, 'python.startNativeREPL', 'Expected command to be python.startNativeREPL'); - assert.equal( - links[0].startIndex, - context.line.indexOf('Ctrl click to launch VS Code Native REPL'), - 'start index should match', - ); - assert.equal(links[0].length, 'Ctrl click to launch VS Code Native REPL'.length, 'Match expected Length'); - assert.equal(links[0].tooltip, Repl.launchNativeRepl, 'Expected tooltip to be Launch VS Code Native REPL'); - } - }); + if (process.platform === 'darwin') { + test('Mac - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => { + const provider = new CustomTerminalLinkProvider(); + const context: TerminalLinkContext = { + line: 'Some random string with Cmd click to launch VS Code Native REPL', + terminal: {} as Terminal, + }; + const token: CancellationToken = { + isCancellationRequested: false, + onCancellationRequested: new EventEmitter().event, + }; + + const links = provider.provideTerminalLinks(context, token); + + assert.isNotNull(links, 'Expected links to be not undefined'); + assert.isArray(links, 'Expected links to be an array'); + assert.isNotEmpty(links, 'Expected links to be not empty'); + + if (Array.isArray(links)) { + assert.equal( + links[0].command, + 'python.startNativeREPL', + 'Expected command to be python.startNativeREPL', + ); + assert.equal( + links[0].startIndex, + context.line.indexOf('Cmd click to launch VS Code Native REPL'), + 'start index should match', + ); + assert.equal( + links[0].length, + 'Cmd click to launch VS Code Native REPL'.length, + 'Match expected length', + ); + assert.equal( + links[0].tooltip, + Repl.launchNativeRepl, + 'Expected tooltip to be Launch VS Code Native REPL', + ); + } + }); + } + if (process.platform !== 'darwin') { + test('Windows/Linux - Verify provideTerminalLinks returns links when context.line contains expectedNativeLink', () => { + const provider = new CustomTerminalLinkProvider(); + const context: TerminalLinkContext = { + line: 'Some random string with Ctrl click to launch VS Code Native REPL', + terminal: {} as Terminal, + }; + const token: CancellationToken = { + isCancellationRequested: false, + onCancellationRequested: new EventEmitter().event, + }; + + const links = provider.provideTerminalLinks(context, token); + + assert.isNotNull(links, 'Expected links to be not undefined'); + assert.isArray(links, 'Expected links to be an array'); + assert.isNotEmpty(links, 'Expected links to be not empty'); + + if (Array.isArray(links)) { + assert.equal( + links[0].command, + 'python.startNativeREPL', + 'Expected command to be python.startNativeREPL', + ); + assert.equal( + links[0].startIndex, + context.line.indexOf('Ctrl click to launch VS Code Native REPL'), + 'start index should match', + ); + assert.equal( + links[0].length, + 'Ctrl click to launch VS Code Native REPL'.length, + 'Match expected Length', + ); + assert.equal( + links[0].tooltip, + Repl.launchNativeRepl, + 'Expected tooltip to be Launch VS Code Native REPL', + ); + } + }); + } test('Verify provideTerminalLinks returns no links when context.line does not contain expectedNativeLink', () => { const provider = new CustomTerminalLinkProvider();