slackhq / slackhq/vscode-hack

Diagnostics from remote Docker Hack LSP are mapped to the first workspace folder

Open
#263 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
80
Forks
47
PR merge metrics
No merged PRs in 30d

Description

When using hack.remote.enabled with Docker in a multi-root workspace, Hack
diagnostics are mapped to workspaceFolders[0] instead of the workspace folder
that corresponds to hack.remote.workspacePath.

In this repro, the real Hack error is in hack/type_error.hack, but VS Code
reports it against not-hack/type_error.hack.

Code reference

https://github.com/slackhq/vscode-hack/blob/559abd48722fc16e2fb27c5874259563d8f55b66/src/Config.ts#L55-L62

Note how it takes workspaceFolders![0]

Expected

The diagnostic points to:

hack/type_error.hack

Actual

The diagnostic points to:

not-hack/type_error.hack

That file does not exist.

Notes

If the hack folder is moved to the first position in the workspace file and
the window is reloaded, the same diagnostic points to the correct file.

Repro script

Run this script in an empty directory to recreate a minimal reproduction case.

#!/usr/bin/env sh
set -eu

root=hack-vscode-wrong-root-repro
rm -rf "$root"
mkdir -p "$root/not-hack" "$root/hack"

cat > "$root/hack-vscode-wrong-root-repro.code-workspace" <<'JSON'
{
  "folders": [
    {
      "name": "not-hack",
      "path": "not-hack"
    },
    {
      "name": "hack",
      "path": "hack"
    }
  ],
  "settings": {
    "hack.remote.docker.containerName": "hack-vscode-wrong-root-repro-hack-1",
    "hack.remote.enabled": true,
    "hack.remote.type": "docker",
    "hack.remote.workspacePath": "/mnt/project"
  }
}
JSON

cat > "$root/docker-compose.yml" <<'YAML'
name: hack-vscode-wrong-root-repro

services:
  hack:
    image: hhvm/hhvm:latest
    working_dir: /mnt/project
    command: sleep infinity
    volumes:
      - type: bind
        source: ./hack
        target: /mnt/project
YAML

touch "$root/not-hack/some_other_file.txt"
touch "$root/hack/.hhconfig"

cat > "$root/hack/type_error.hack" <<'HACK'
const string X = 0;
HACK

cd "$root"
docker compose up -d

Then open hack-vscode-wrong-root-repro.code-workspace in VS Code with the
Hack extension enabled.

Contributor guide

Open the contributing guide

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 src/Config.ts lines 55-62, where the remote workspace mapping uses the first workspace folder. Run the supplied Docker multi-root reproduction and inspect how hack.remote.workspacePath is matched to a workspace folder. Done when the diagnostic for hack/type_error.hack is reported against that file even when the hack folder is not first.

Written by the indexing model from the issue text.

Assessment

Tech stack
docker, typescript, vscode
Domain
devtools
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
68/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.