Skip to content

Commit ec8216b

Browse files
committed
Add support for multiple folder
1 parent ec93303 commit ec8216b

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "laravel-goto-view",
33
"displayName": "Laravel goto view",
44
"description": "Quick jump to view",
5-
"version": "1.1.2",
5+
"version": "1.1.3",
66
"publisher": "codingyu",
77
"engines": {
88
"vscode": "^1.15.0"

src/extension.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ export function activate(context: ExtensionContext) {
1111
provideHover(document, position, token) {
1212
let linkRange = document.getWordRangeAtPosition(position, REG);
1313
if(linkRange){
14-
let filePath = util.getFilePath(document.getText(linkRange));
14+
let filePath = util.getFilePath(document.getText(linkRange), document);
15+
let workspaceFolder = workspace.getWorkspaceFolder(document.uri);
1516
if(filePath != null){
16-
return new Hover(filePath.replace(workspace.rootPath + '/',''));
17+
return new Hover(workspaceFolder.name + filePath.replace(workspaceFolder.uri.fsPath,''));
1718
}
1819
}
1920
return;

src/link.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ export class LinkProvider implements DocumentLinkProvider {
1313
let result = line.text.match(reg);
1414
if (result != null) {
1515
for (let item of result) {
16-
let filePath = util.getFilePath(item);
16+
let filePath = util.getFilePath(item, document);
1717
if(filePath != null){
18-
let start = new Position(line.lineNumber, line.text.indexOf(item));
19-
let end = start.translate(0, item.length);
18+
let start = new Position(line.lineNumber, line.text.indexOf(item) + 1);
19+
let end = start.translate(0, item.length - 2);
2020
let documentlink = new DocumentLink(new Range(start, end), Uri.file(filePath));
2121
documentLinks.push(documentlink);
2222
};

src/util.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
'use strict';
22

3-
import { workspace } from 'vscode';
3+
import { workspace, TextDocument } from 'vscode';
44
import * as fs from "fs";
55

6-
export function getFilePath(text:string) {
7-
let filePath = workspace.rootPath + "/resources/views/" + text.replace(/\./g,'/').replace(/\"|\'/g,'') + ".blade.php";
6+
export function getFilePath(text:string, document:TextDocument) {
7+
let filePath = workspace.getWorkspaceFolder(document.uri).uri.fsPath + "/resources/views/" + text.replace(/\./g,'/').replace(/\"|\'/g,'') + ".blade.php";
88
if(fs.existsSync(filePath)){
99
return filePath;
1010
}else{

0 commit comments

Comments
 (0)