Support mnemonic prefixes in git diff parsing for terminal links#298490
Open
clintharrison wants to merge 2 commits intomicrosoft:mainfrom
Open
Support mnemonic prefixes in git diff parsing for terminal links#298490clintharrison wants to merge 2 commits intomicrosoft:mainfrom
clintharrison wants to merge 2 commits intomicrosoft:mainfrom
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
Pull request overview
Updates VS Code’s integrated terminal local-file link parsing so filenames in git diff output are correctly detected when diff.mnemonicPrefix is enabled (eg. i/ and w/ instead of a/ and b/), preventing links from including the mnemonic prefix as part of the path.
Changes:
- Generalize git-diff prefix stripping to support mnemonic prefixes via small regex helpers.
- Expand existing git-diff parsing tests to cover the additional mnemonic prefixes.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts | Adds regex-based detection of git diff prefixes (a/, b/, c/, i/, o/, w/) so link ranges exclude the prefix consistently. |
| src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts | Parameterizes git-diff link parsing tests to validate mnemonic-prefix handling. |
src/vs/workbench/contrib/terminalContrib/links/browser/terminalLinkParsing.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts
Show resolved
Hide resolved
src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalLinkParsing.test.ts
Show resolved
Hide resolved
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Git supports a config option
diff.mnemonicPrefixthat sometimes uses characters other thana/andb/in diffs to distinguish where they came from. This PR updates the link parsing in the integrated terminal, so file paths are still detected when this option is enabled.I updated the existing tests for this functionality.
Manual testing
Make some change in a git repo (e.g.
echo "hello world" >>README.md).Enable this config option and run git diff:
git -c diff.mnemonicPrefix=true diffin the terminal will now be comparing theindex and theworking copy files:With this change,
README.mdin each location should be underlined on hover and possible to open with ⌘/ctrl+click.Notably, cmd-click will open
README.md, and not attempt to find a file namedw/README.md