Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to reverse the sort order in explorer #149952

Merged
merged 8 commits into from
Jul 30, 2024
6 changes: 6 additions & 0 deletions src/vs/workbench/contrib/files/browser/explorerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ export class ExplorerService implements IExplorerService {
return {
sortOrder: this.config.sortOrder,
lexicographicOptions: this.config.sortOrderLexicographicOptions,
reverse: this.config.sortOrderReverse,
};
}

Expand Down Expand Up @@ -521,6 +522,11 @@ export class ExplorerService implements IExplorerService {
if (this.config.sortOrderLexicographicOptions !== configLexicographicOptions) {
shouldRefresh = shouldRefresh || this.config.sortOrderLexicographicOptions !== undefined;
}
const sortOrderReverse = configuration?.explorer?.sortOrderReverse || false;

if (this.config.sortOrderReverse !== sortOrderReverse) {
shouldRefresh = shouldRefresh || this.config.sortOrderReverse !== undefined;
}

this.config = configuration.explorer;

Expand Down
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/files/browser/files.contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,11 @@ configurationRegistry.registerConfiguration({
],
'description': nls.localize('sortOrderLexicographicOptions', "Controls the lexicographic sorting of file and folder names in the Explorer.")
},
'explorer.sortOrderReverse': {
'type': 'boolean',
'description': nls.localize('sortOrderReverse', "Controls whether the file and folder sort order, should be reversed."),
'default': false,
},
'explorer.decorations.colors': {
type: 'boolean',
description: nls.localize('explorer.decorations.colors', "Controls whether file decorations should use colors."),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -880,6 +880,10 @@ export class FileSorter implements ITreeSorter<ExplorerItem> {

const sortOrder = this.explorerService.sortOrderConfiguration.sortOrder;
const lexicographicOptions = this.explorerService.sortOrderConfiguration.lexicographicOptions;
const reverse = this.explorerService.sortOrderConfiguration.reverse;
if (reverse) {
[statA, statB] = [statB, statA];
}

let compareFileNames;
let compareFileExtensions;
Expand Down
2 changes: 2 additions & 0 deletions src/vs/workbench/contrib/files/common/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export interface IFilesConfiguration extends PlatformIFilesConfiguration, IWorkb
expandSingleFolderWorkspaces: boolean;
sortOrder: SortOrder;
sortOrderLexicographicOptions: LexicographicOptions;
sortOrderReverse: boolean;
decorations: {
colors: boolean;
badges: boolean;
Expand Down Expand Up @@ -143,6 +144,7 @@ export const enum LexicographicOptions {
export interface ISortOrderConfiguration {
sortOrder: SortOrder;
lexicographicOptions: LexicographicOptions;
reverse: boolean;
}

export class TextFileContentProvider extends Disposable implements ITextModelContentProvider {
Expand Down
Loading