Skip to content

feat: add path mapping functionality for JetBrains IDE integration - #13

Open
olegius88 wants to merge 2 commits into
denisbalber:mainfrom
olegius88:feature/path-mapping
Open

olegius88 wants to merge 2 commits into
denisbalber:mainfrom
olegius88:feature/path-mapping

Conversation

@olegius88

Copy link
Copy Markdown

This PR adds path mapping functionality to enable seamless integration between JetBrains IDEs and VS Code when projects are located in different environments (e.g., Windows host vs. Docker container).

Added

  • Path mapping configuration with three new settings:
    • vscode-jetbrains-sync.pathMapping.enabled: Enable/disable the feature
    • vscode-jetbrains-sync.pathMapping.sourcePattern: Regex pattern to match source paths
    • vscode-jetbrains-sync.pathMapping.targetPath: Target path for replacement

Improved

  • Error messages now show transformed paths instead of original paths
  • Better configuration UI with examples and descriptions
  • Robust error handling for invalid regex patterns

Use Case

When the same project is open in:

  • JetBrains IDE on Windows: I:/_SendAPI/sendapi-projects-root-v01/
  • VS Code in Docker container: /workspace/

The extension now transforms incoming file paths automatically:
I:/_SendAPI/sendapi-projects-root-v01/service/app.js → /workspace/service/app.js

Testing

  • ✅ Path transformation works correctly with regex patterns
  • ✅ Error handling for invalid patterns
  • ✅ Configuration UI displays properly
  • ✅ Backwards compatibility maintained when feature is disabled

This PR adds path mapping functionality to enable seamless integration between JetBrains IDEs and VS Code when projects are located in different environments (e.g., Windows host vs. Docker container).

### Added
- Path mapping configuration with three new settings:
  - vscode-jetbrains-sync.pathMapping.enabled: Enable/disable the feature
  - vscode-jetbrains-sync.pathMapping.sourcePattern: Regex pattern to match source paths
  - vscode-jetbrains-sync.pathMapping.targetPath: Target path for replacement

### Improved
- Error messages now show transformed paths instead of original paths
- Better configuration UI with examples and descriptions
- Robust error handling for invalid regex patterns

### Use Case
When the same project is open in:
- JetBrains IDE on Windows: I:/_SendAPI/sendapi-projects-root-v01/
- VS Code in Docker container: /workspace/

The extension now transforms incoming file paths automatically:
I:/_SendAPI/sendapi-projects-root-v01/service/app.js → /workspace/service/app.js

### Testing
- Path transformation works correctly with regex patterns
- Error handling for invalid patterns
- Configuration UI displays properly
- Backwards compatibility maintained when feature is disabled
Copilot AI review requested due to automatic review settings September 16, 2025 10:38

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds path mapping functionality to enable seamless integration between JetBrains IDEs and VS Code when projects are located in different environments, such as Windows host vs Docker container. The feature allows automatic transformation of incoming file paths using regex patterns.

  • Adds configurable path mapping with source pattern matching and target path replacement
  • Transforms file paths in error messages to show mapped paths instead of original paths
  • Includes comprehensive configuration settings with examples and validation

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
vscode-extension/src/extension.ts Implements path transformation logic and applies it to incoming file operations
vscode-extension/package.json Adds three new configuration settings for path mapping functionality
vscode-extension/CHANGELOG.md Minor formatting change with empty line addition

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread vscode-extension/src/extension.ts Outdated
Comment thread vscode-extension/src/extension.ts Outdated
- Optimize path transformation by calling transformIncomingFilePath only once per method
- Improve error message specificity by indicating which configuration values are missing
- Move path transformation to beginning of handleIncomingState method to avoid redundant computation
@olegius88
olegius88 requested a review from Copilot September 16, 2025 10:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

}

try {
const regex = new RegExp(sourcePattern, 'g');

Copilot AI Sep 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using the global flag 'g' with replace() can cause unexpected behavior when the same RegExp object is reused, as it maintains state between calls. Consider removing the 'g' flag since replace() will replace all occurrences by default when using a string replacement.

Suggested change
const regex = new RegExp(sourcePattern, 'g');
const regex = new RegExp(sourcePattern);

Copilot uses AI. Check for mistakes.
"type": "string",
"default": "",
"description": "Target path to replace the matched source pattern",
"scope": "window",

Copilot AI Sep 16, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's trailing whitespace after the comma on this line. Remove the extra space for consistency.

Suggested change
"scope": "window",
"scope": "window",

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants