@@ -31,7 +31,7 @@ export class GoMethodExtractor implements IMethodExtractor{
3131 }
3232
3333 const modFiles = await vscode . workspace . findFiles ( '**/go.mod' ) ;
34- const modFile = modFiles . find ( f => document . uri . path . startsWith ( path . dirname ( f . path ) ) ) ;
34+ const modFile = modFiles . find ( f => document . uri . fsPath . startsWith ( path . dirname ( f . fsPath ) ) ) ;
3535 if ( ! modFile ) {
3636 Logger . warn ( `Could not resolve mod file for '${ document . uri . path } '` ) ;
3737 return [ ] ;
@@ -45,13 +45,19 @@ export class GoMethodExtractor implements IMethodExtractor{
4545 if ( ! packageDefinitionName ) {
4646 return [ ] ;
4747 }
48- const modFolder = path . dirname ( modFile . path ) ;
49- const docFolder = path . dirname ( document . uri . path ) ;
48+ let packagePath = moduleName ;
5049
51- let packagePath = `${ moduleName } /${ path . relative ( modFolder , docFolder . replaceAll ( '\\' , '/' ) ) } ` ; // get rid of windows backslashes
52- if ( packageDefinitionName === "main" ) {
53- packagePath = moduleName ;
50+ if ( packageDefinitionName !== "main" ) {
51+ const modFolder = path . dirname ( modFile . fsPath ) ;
52+ const docFolder = path . dirname ( document . uri . fsPath ) ;
53+
54+ if ( docFolder !== modFolder ) {
55+ const relative = path . relative ( modFolder , docFolder )
56+ . replaceAll ( '\\' , '/' ) ; // get rid of windows backslashes
57+ packagePath = moduleName + "/" + relative ;
58+ }
5459 }
60+
5561 const methods : SymbolInfo [ ] = methodSymbols . map ( s => {
5662 return {
5763 id : packageDefinitionName === "main" ? packagePath + '$_$' + `main.${ s . name } ` : packagePath + '$_$' + s . name ,
0 commit comments