-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
close #151
- Loading branch information
Showing
18 changed files
with
272 additions
and
53 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
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
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 +1,2 @@ | ||
export const HAS_FOLDERS = 'foldersCompareContext.hasFolders'; | ||
export const HAS_FOLDERS = 'foldersCompareContext.hasFolders' as const; | ||
export const FILES_VIEW_MODE = 'foldersCompare.diffViewMode' as const; |
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,5 +1,8 @@ | ||
import { commands } from 'vscode'; | ||
import { HAS_FOLDERS, type FILES_VIEW_MODE } from '../constants/contextKeys'; | ||
|
||
export const setContext = (key: string, value: string | boolean): void => { | ||
type ContextKey = typeof HAS_FOLDERS | typeof FILES_VIEW_MODE; | ||
|
||
export const setContext = (key: ContextKey, value: string | boolean): void => { | ||
commands.executeCommand('setContext', key, value); | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { getConfiguration } from '../services/configuration'; | ||
import { setContext } from './global'; | ||
|
||
export type DiffViewMode = 'tree' | 'list'; | ||
|
||
class UIContext { | ||
private _diffViewMode?: DiffViewMode; | ||
|
||
init() { | ||
this.updateFromConfiguration(); | ||
} | ||
|
||
updateFromConfiguration() { | ||
// don't update from configuration if diffViewMode is already set | ||
if (this._diffViewMode) { | ||
return; | ||
} | ||
this.diffViewMode = getConfiguration('defaultDiffViewMode'); | ||
} | ||
|
||
set diffViewMode(mode: DiffViewMode) { | ||
setContext('foldersCompare.diffViewMode', mode); | ||
this._diffViewMode = mode; | ||
} | ||
|
||
get diffViewMode(): DiffViewMode { | ||
return this._diffViewMode || getConfiguration('defaultDiffViewMode'); | ||
} | ||
} | ||
|
||
export const uiContext = new UIContext(); |
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
Oops, something went wrong.