forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Launch Native REPL using terminal link #24734
Merged
anthonykim1
merged 22 commits into
microsoft:main
from
anthonykim1:shellintegrationLink
Jan 23, 2025
+151
−2
Merged
Changes from 9 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
d1f0b8c
initial set to link pythonrc text to native repl launch.
anthonykim1 8854bb6
add question
anthonykim1 78a25a4
do not use vscode.command.executeCommand directly
anthonykim1 590b6cb
avoid using windows vscode method directly, better separate customLin…
anthonykim1 cb63ae7
compile
anthonykim1 f9093d8
Take feedback
anthonykim1 93d8e77
change wording
anthonykim1 2724718
add python test
anthonykim1 6e216e2
add typescript test
anthonykim1 51c6620
stop messing with other tests
anthonykim1 c053215
remove pytest
anthonykim1 ae09a31
attempting to fix wrongly caches monkeypatch
anthonykim1 7b00e95
fix
anthonykim1 94cef91
i
anthonykim1 b39dcd1
double quote
anthonykim1 f9e2f85
ruff my imports
anthonykim1 541849b
reformat for the very last time
anthonykim1 ee8909f
address feedback, cleanup
anthonykim1 c648fda
add more test
anthonykim1 0a07887
remove unused
anthonykim1 c98e18d
more tests
anthonykim1 fb0fa8d
negative test case against provideTerminalLinks
anthonykim1 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
/* eslint-disable class-methods-use-this */ | ||
import { | ||
CancellationToken, | ||
Disposable, | ||
ProviderResult, | ||
TerminalLink, | ||
TerminalLinkContext, | ||
TerminalLinkProvider, | ||
l10n, | ||
} from 'vscode'; | ||
import { executeCommand } from '../common/vscodeApis/commandApis'; | ||
import { registerTerminalLinkProvider } from '../common/vscodeApis/windowApis'; | ||
|
||
interface CustomTerminalLink extends TerminalLink { | ||
command: string; | ||
} | ||
|
||
export class CustomTerminalLinkProvider implements TerminalLinkProvider<CustomTerminalLink> { | ||
provideTerminalLinks( | ||
context: TerminalLinkContext, | ||
_token: CancellationToken, | ||
): ProviderResult<CustomTerminalLink[]> { | ||
const links: CustomTerminalLink[] = []; | ||
// Question: What if context.line is truncated because of user zoom setting? | ||
anthonykim1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
// Meaning what if this line is separated into two+ line in terminal? | ||
const expectedNativeLink = 'VS Code Native REPL'; | ||
|
||
// eslint-disable-next-line no-cond-assign | ||
anthonykim1 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (context.line.includes(expectedNativeLink)) { | ||
links.push({ | ||
startIndex: context.line.indexOf(expectedNativeLink), | ||
length: expectedNativeLink.length, | ||
tooltip: l10n.t('Launch VS Code Native REPL'), | ||
command: 'python.startNativeREPL', | ||
}); | ||
} | ||
return links; | ||
} | ||
|
||
async handleTerminalLink(link: CustomTerminalLink): Promise<void> { | ||
await executeCommand(link.command); | ||
} | ||
} | ||
|
||
export function registerCustomTerminalLinkProvider(disposables: Disposable[]): void { | ||
disposables.push(registerTerminalLinkProvider(new CustomTerminalLinkProvider())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it weird if only part of this string is fixed to create a link with l10n? Will that translate only half the command?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean
tooltip: l10n.t('Launch VS Code Native REPL'),
part?I think the the tooltip would only show
Launch VS Code Native REPL