vuejs / vuejs/devtools

Opening wsl2 hosted files in idea.

Open
#594 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

upstream
Dominant language
TypeScript
Stars
2.9k
Forks
279
PR merge metrics
No merged PRs in 30d

Description

I know this is something extremely low-priority guys, but some of us, clone repos inside of wsl2 env, and use idea from windows.

So if I configure idea as editor doing this:

vueDevTools({
    launchEditor: 'idea',
}),

In first instance, the plugin fails as it can't find idea in the path, so I made a /usr/local/bin bash script to pass the commands to Windows idea

#!/bin/bash
/mnt/c/Windows/explorer.exe 'C:\Users\MyWindowsUser\AppData\Local\JetBrains\Toolbox\scripts\idea.cmd' "$@"

This worked but now the plugin is trying to open files using Ubuntu paths like /home/ubuntu/path/to/my/repo/App.vue

So I've ended up doing some sorcery

#!/bin/bash
#  echo "Original args: $@" 1>&2
# Function to decode URL-encoded strings
urldecode() {
    local url_encoded="${1//+/ }"
    printf '%b' "${url_encoded//%/\\x}"
}

# Function to convert WSL path to Windows path
wsl_to_windows_path() {
    wsl_path="$1"
    windows_path=$(wslpath -w "$wsl_path")
    echo "$windows_path"
}

# Define the IntelliJ IDEA script path directly as a Windows path
idea_cmd="C:\\Users\\$(cmd.exe /C echo %USERNAME% | tr -d '\r')\\AppData\\Local\\JetBrains\\Toolbox\\scripts\\idea.cmd"

# Iterate over all arguments and decode and convert paths if they exist
args=()
for arg in "$@"; do
    # echo "Original arg: $arg" 1>&2
    decoded_arg=$(urldecode "$arg")
    # echo "Decoded arg: $decoded_arg" 1>&2
    if [[ "$decoded_arg" == /* ]]; then
        # Extract the path after 'file=' and convert it
        wsl_path="${decoded_arg#file=}"
        wsl_path="${wsl_path%%:*}"  # Strip line:column info (e.g., :0:0)
        windows_arg=$(wsl_to_windows_path "$wsl_path")
        # echo "Converted path: $windows_arg" 1>&2
        args+=("\"$windows_arg\"")
    else
        args+=("$decoded_arg")
    fi
done
# Combine arguments into a single string for correct grouping
combined_args=$(printf "%s " "${args[@]}")

# Print final arguments for debugging
echo "opening: ${combined_args}" 1>&2

# Call the IntelliJ IDEA script with the translated paths using Windows paths
eval "cmd.exe /C  '$idea_cmd ${combined_args}' 1>&2"

It is ugly and dirty, but it works and now I can open files from your marvelous plugin.

Someone could make this kind of conversion as part of the plugin. If nobody picks this glove, I'll try to make a PR but it can take some time for that.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the launchEditor: 'idea' integration shown in the issue and trace how file arguments are assembled; no repository file or test is named. Use the reported WSL bash wrapper as behavioral reference. Done means IDEA can open files from a WSL2-hosted repository when launched from the plugin without manual path conversion.

Written by the indexing model from the issue text.

Assessment

Tech stack
bash, linux, typescript
Domain
devtools, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.