juanfranblanco / vscode-solidity

Visual Studio Code language support extension for Solidity smart contracts in Ethereum https://marketplace.visualstudio.com/items?itemName=JuanBlanco.solidity
MIT License
892 stars 191 forks source link

fix import path resolving to absolute rather than project root (#450) #459

Closed chanleyou closed 3 weeks ago

chanleyou commented 3 months ago

Fixes issue #450.

Folder Structure

project/
├── src/
│   ├── MyContract.sol
└── test/
    └── MyContract.t.sol

MyContract.t.sol

import {MyContract} from "src/MyContract.sol";

Currently, "Go to Definition (F12 or Ctrl + Click)" doesn't work on this import statement as it defaults to the user file system's absolute path. However, imports relative to project root do work and compile without issues by default on Hardhat, Foundry and Brownie.

The current behaviour (resolving to absolute path) is not supported by the solidity compiler or any of them either, see HH407.