-
-
Notifications
You must be signed in to change notification settings - Fork 219
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #138 from andresrgz/wsl-enhancements
Enhancements for WSL support
- Loading branch information
Showing
5 changed files
with
55 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,40 @@ | ||
import * as vscode from 'vscode'; | ||
import * as state from '../state'; | ||
import * as util from '../utilities'; | ||
export default class DefinitionProvider implements vscode.DefinitionProvider { | ||
state: any; | ||
constructor() { | ||
this.state = state; | ||
} | ||
|
||
async provideDefinition(document, position, token) { | ||
let text = util.getWordAtPosition(document, position); | ||
let client = util.getSession(util.getFileType(document)); | ||
if(this.state.deref().get('connected')) { | ||
let info = await client.info(util.getNamespace(document.getText()), text); | ||
if(info.file && info.file.length > 0) { | ||
let pos = new vscode.Position(info.line - 1, info.column); | ||
return new vscode.Location(vscode.Uri.parse(info.file), pos); | ||
} | ||
} | ||
} | ||
}; | ||
import * as vscode from 'vscode'; | ||
import * as state from '../state'; | ||
import * as util from '../utilities'; | ||
import { wslToWindows } from 'wsl-path'; | ||
|
||
export class DefinitionProvider implements vscode.DefinitionProvider { | ||
state: any; | ||
constructor() { | ||
this.state = state; | ||
} | ||
|
||
async provideDefinition(document, position, token) { | ||
let text = util.getWordAtPosition(document, position); | ||
let client = util.getSession(util.getFileType(document)); | ||
if(this.state.deref().get('connected')) { | ||
let info = await client.info(util.getNamespace(document.getText()), text); | ||
if(info.file && info.file.length > 0) { | ||
let pos = new vscode.Position(info.line - 1, info.column); | ||
return new vscode.Location(vscode.Uri.parse(info.file), pos); | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export class WslDefinitionProvider extends DefinitionProvider { | ||
async provideDefinition(document, position, token) { | ||
const location = await super.provideDefinition(document, position, token); | ||
if (!location) return; | ||
|
||
if (location.uri.scheme === 'jar') { | ||
const path = vscode.Uri.parse(location.uri.path).path; | ||
const windowsFilePath = await wslToWindows(path); | ||
const windowsFileUri = vscode.Uri.file(windowsFilePath); | ||
return new vscode.Location(location.uri.with({ path: `file:${windowsFileUri.path}`}), location.range); | ||
} | ||
|
||
const windowsFilePath = await wslToWindows(location.uri.path); | ||
return new vscode.Location(vscode.Uri.file(windowsFilePath), location.range); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters