Skip to content

Commit e6070ad

Browse files
authored
Feature/ReFix PRs 117 and 118 - windows related (#121)
1 parent 95aefd0 commit e6070ad

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

src/services/languages/go/methodExtractor.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)