|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -import { workspace, languages, Hover, ExtensionContext} from 'vscode'; |
| 3 | +import { workspace, languages, Hover, ExtensionContext, MarkdownString, Uri} from 'vscode'; |
4 | 4 | import { LinkProvider } from './link'; |
5 | 5 | import * as util from './util'; |
6 | 6 |
|
7 | 7 | const REG = /(['"])[^'"]*\1/; |
8 | 8 |
|
9 | 9 | export function activate(context: ExtensionContext) { |
| 10 | + let config = workspace.getConfiguration('laravel_goto_view'); |
10 | 11 | let hover = languages.registerHoverProvider(['php','blade','laravel-blade'], { |
11 | 12 | provideHover(document, position, token) { |
12 | 13 | let linkRange = document.getWordRangeAtPosition(position, REG); |
13 | 14 | if(linkRange){ |
14 | | - let filePath = util.getFilePath(document.getText(linkRange), document); |
| 15 | + let filePaths = util.getFilePaths(document.getText(linkRange), document); |
15 | 16 | let workspaceFolder = workspace.getWorkspaceFolder(document.uri); |
16 | | - if(filePath != null){ |
17 | | - return new Hover(workspaceFolder.name + filePath.replace(workspaceFolder.uri.fsPath,'')); |
| 17 | + if(filePaths.length > 0){ |
| 18 | + let text:string = ""; |
| 19 | + for (let i in filePaths) { |
| 20 | + text += i == '0' ? `- \`Default\`` : `- \`Other\``; |
| 21 | + text += ` [${workspaceFolder.name + filePaths[i].showPath}](${filePaths[i].fileUri})\n`; |
| 22 | + } |
| 23 | + return new Hover(new MarkdownString(text)); |
18 | 24 | } |
19 | 25 | } |
20 | 26 | return; |
21 | 27 | } |
22 | 28 | }); |
23 | | - let link = languages.registerDocumentLinkProvider(['php','blade','laravel-blade'], new LinkProvider()); |
24 | | - context.subscriptions.push(hover); |
25 | | - context.subscriptions.push(link); |
| 29 | + context.subscriptions.push(hover); |
| 30 | + |
| 31 | + if (config.quick_click) { |
| 32 | + let link = languages.registerDocumentLinkProvider(['php','blade','laravel-blade'], new LinkProvider()); |
| 33 | + context.subscriptions.push(link); |
| 34 | + } |
26 | 35 | } |
27 | 36 |
|
28 | 37 | export function deactivate() { |
|
0 commit comments