@@ -15,9 +15,11 @@ import { searchSelectionCommand } from './commands/searchSelectionCommand'
1515import { SourcegraphHoverProvider } from './code-intel/SourcegraphHoverProvider'
1616import { SourcegraphDefinitionProvider } from './code-intel/SourcegraphDefinitionProvider'
1717import { SourcegraphReferenceProvider } from './code-intel/SourcegraphReferenceProvider'
18- import { SourcegraphTreeDataProvider } from './file-system/SourcegraphTreeDataProvider '
18+ import { FilesTreeDataProvider } from './file-system/FilesTreeDataProvider '
1919import { switchGitRevisionCommand } from './commands/switchGitRevisionCommand'
2020import { openFileInBrowserCommand } from './commands/openFileInBrowserCommand'
21+ import { DiffsTreeDataProvider } from './file-system/DiffsTreeDataProvider'
22+ import { updateCompareRange } from './commands/updateCompareRangeCommand'
2123
2224// eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires
2325const { version } = require ( '../package.json' )
@@ -74,14 +76,36 @@ export function activate(context: vscode.ExtensionContext): void {
7476 vscode . languages . registerHoverProvider ( { scheme : 'sourcegraph' } , new SourcegraphHoverProvider ( fs ) )
7577 vscode . languages . registerDefinitionProvider ( { scheme : 'sourcegraph' } , new SourcegraphDefinitionProvider ( fs ) )
7678 vscode . languages . registerReferenceProvider ( { scheme : 'sourcegraph' } , referenceProvider )
77- const treeDataProvider = new SourcegraphTreeDataProvider ( fs )
78- const treeView = vscode . window . createTreeView < string > ( 'sourcegraph.files' , {
79- treeDataProvider,
79+
80+ const filesTreeProvider = new FilesTreeDataProvider ( fs )
81+ const filesTreeView = vscode . window . createTreeView < string > ( 'sourcegraph.files' , {
82+ treeDataProvider : filesTreeProvider ,
8083 showCollapseAll : true ,
8184 } )
82- treeDataProvider . setTreeView ( treeView )
85+ filesTreeProvider . setTreeView ( filesTreeView )
86+
87+ const diffsTreeProvider = new DiffsTreeDataProvider ( fs )
88+ const diffsTreeView = vscode . window . createTreeView ( 'sourcegraph.diffs' , {
89+ treeDataProvider : diffsTreeProvider ,
90+ showCollapseAll : true ,
91+ } )
92+
93+ diffsTreeProvider . setTreeView ( diffsTreeView )
94+ for ( const treeView of [ filesTreeView , diffsTreeView ] ) {
95+ context . subscriptions . push ( treeView )
96+ }
97+
8398 const semanticTokens = new SourcegraphSemanticTokenProvider ( )
84- context . subscriptions . push ( treeView )
99+ for ( const color of [ 'green' , 'orange' , 'red' ] ) {
100+ for ( const index of [ 1 , 2 , 3 ] ) {
101+ const name = `extension.${ color } ${ index } `
102+ context . subscriptions . push (
103+ vscode . commands . registerCommand ( name , ( ) => {
104+ log . appendLine ( `COMMAND ${ name } ` )
105+ } )
106+ )
107+ }
108+ }
85109 context . subscriptions . push (
86110 vscode . commands . registerCommand ( 'extension.goToFileInFolder' , async ( uri : string | undefined ) => {
87111 if ( typeof uri === 'string' ) {
@@ -107,15 +131,20 @@ export function activate(context: vscode.ExtensionContext): void {
107131 vscode . commands . registerCommand (
108132 'extension.switchGitRevision' ,
109133 handleCommandErrors ( 'extension.switchGitRevision' , ( uri : string | undefined ) =>
110- switchGitRevisionCommand ( treeDataProvider , uri )
134+ switchGitRevisionCommand ( filesTreeProvider , uri )
111135 )
112136 )
113137 )
138+ context . subscriptions . push (
139+ vscode . commands . registerCommand ( 'extension.updateCompareRange' , ( ...commandArguments ) => {
140+ updateCompareRange ( diffsTreeProvider , commandArguments )
141+ } )
142+ )
114143 context . subscriptions . push (
115144 vscode . commands . registerCommand (
116145 'extension.openFileInBrowser' ,
117146 handleCommandErrors ( 'extension.openFileInBrowser' , ( uri : string | undefined ) =>
118- openFileInBrowserCommand ( treeDataProvider , uri )
147+ openFileInBrowserCommand ( filesTreeProvider , uri )
119148 )
120149 )
121150 )
@@ -128,7 +157,7 @@ export function activate(context: vscode.ExtensionContext): void {
128157 context . subscriptions . push (
129158 vscode . commands . registerCommand (
130159 'extension.focusActiveFile' ,
131- handleCommandErrors ( 'extension.focusActiveFile' , ( ) => treeDataProvider . focusActiveFile ( ) )
160+ handleCommandErrors ( 'extension.focusActiveFile' , ( ) => filesTreeProvider . focusActiveFile ( ) )
132161 )
133162 )
134163 context . subscriptions . push (
@@ -149,13 +178,15 @@ export function activate(context: vscode.ExtensionContext): void {
149178 { language : 'sourcegraph' } ,
150179 new SourcegraphCompletionItemProvider ( )
151180 )
152- context . subscriptions . push (
153- vscode . window . onDidChangeActiveTextEditor ( editor => treeDataProvider . didFocus ( editor ?. document . uri ) )
154- )
155- treeDataProvider . didFocus ( vscode . window . activeTextEditor ?. document . uri ) . then (
156- ( ) => { } ,
157- ( ) => { }
158- )
181+ for ( const treeProvider of [ filesTreeProvider , diffsTreeProvider ] ) {
182+ context . subscriptions . push (
183+ vscode . window . onDidChangeActiveTextEditor ( editor => treeProvider . didFocus ( editor ?. document . uri ) )
184+ )
185+ treeProvider . didFocus ( vscode . window . activeTextEditor ?. document . uri ) . then (
186+ ( ) => { } ,
187+ ( ) => { }
188+ )
189+ }
159190 vscode . workspace . registerNotebookSerializer ( 'sourcegraph-notebook' , new SourcegraphNotebookSerializer ( fs ) , { } )
160191}
161192
0 commit comments