()
| 49 | |
| 50 | // initialize the VSCode's state according to the router url |
| 51 | const initialVSCodeState = async () => { |
| 52 | const routerState = await router.getState(); |
| 53 | const scheme = adapterManager.getCurrentScheme(); |
| 54 | |
| 55 | if (routerState.pageType === PageType.Tree && routerState.filePath) { |
| 56 | vscode.commands.executeCommand( |
| 57 | 'revealInExplorer', |
| 58 | vscode.Uri.parse('').with({ scheme, path: `/${routerState.filePath}` }), |
| 59 | ); |
| 60 | } else if (routerState.pageType === PageType.Blob && routerState.filePath) { |
| 61 | const { startLine, endLine } = routerState; |
| 62 | let documentShowOptions: vscode.TextDocumentShowOptions = {}; |
| 63 | if (startLine || endLine) { |
| 64 | const startPosition = new vscode.Position((startLine || endLine)! - 1, 0); |
| 65 | const endPosition = new vscode.Position((endLine || startLine)! - 1, 1 << 20); |
| 66 | documentShowOptions = { selection: new vscode.Range(startPosition, endPosition) }; |
| 67 | } |
| 68 | vscode.window.showTextDocument( |
| 69 | vscode.Uri.parse('').with({ scheme, path: `/${routerState.filePath}` }), |
| 70 | documentShowOptions, |
| 71 | ); |
| 72 | } else if (routerState.pageType === PageType.CodeReviewList) { |
| 73 | vscode.commands.executeCommand('github1s.views.codeReviewList.focus'); |
| 74 | } else if (routerState.pageType === PageType.CommitList) { |
| 75 | vscode.commands.executeCommand('github1s.views.commitList.focus'); |
| 76 | } else if ([PageType.CodeReview, PageType.Commit].includes(routerState.pageType)) { |
| 77 | vscode.commands.executeCommand('workbench.scm.focus'); |
| 78 | } else if (routerState.pageType === PageType.Search) { |
| 79 | vscode.commands.executeCommand('workbench.action.findInFiles', routerState); |
| 80 | } |
| 81 | routerState.repo && addRecentRepositories(routerState.repo); |
| 82 | }; |
no test coverage detected