Skip to content

Commit

Permalink
perf: Remove some deprecated code
Browse files Browse the repository at this point in the history
  • Loading branch information
weirongxu committed Jun 12, 2024
1 parent aa5f69f commit 237f89d
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 135 deletions.
18 changes: 0 additions & 18 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -783,12 +783,6 @@
"dirPatternMatches": {}
}
},
"explorer.icon.enableVimDevicons": {
"deprecationMessage": "The configuration `explorer.icon.enableVimDevicons` has been deprecated, please use `{\"explorer.icon.enableNerdfont\": true, \"explorer.icon.source\": \"vim-devicons\"}` instead of it",
"description": "Enable use vim-devicons instead of built-in icon configuration",
"type": "boolean",
"default": null
},
"explorer.icon.expanded": {
"description": "Icon for expanded node",
"type": "string",
Expand Down Expand Up @@ -867,18 +861,6 @@
"type": "string",
"default": "yy/MM/dd HH:mm:ss"
},
"explorer.file.revealWhenOpen": {
"deprecationMessage": "Use explorer.file.reveal.whenOpen instead of it",
"description": "Explorer will automatically reveal to the current buffer when open explorer",
"type": "boolean",
"default": null
},
"explorer.file.autoReveal": {
"deprecationMessage": "Use explorer.file.reveal.auto instead of it",
"description": "Explorer will automatically expand to the current buffer",
"type": "boolean",
"default": null
},
"explorer.file.reveal.whenOpen": {
"description": "Explorer will automatically reveal to the current buffer when open explorer",
"type": "boolean",
Expand Down
32 changes: 2 additions & 30 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { workspace, type WorkspaceConfiguration } from 'coc.nvim';
import type { OriginalActionExp } from './actions/types';
import type { CollapseOption, ExpandOption, RootStrategyStr } from './types';
import type { Explorer } from './types/pkg-config';
import { generateUri, logger } from './util';
import { generateUri } from './util';

export const config = workspace.getConfiguration('explorer');

Expand Down Expand Up @@ -56,42 +56,14 @@ export const bufferTabOnly = () => {
return config.get<boolean>('buffer.tabOnly')!;
};

/**
* @deprecated
*/
export const getRevealAuto = (config: ExplorerConfig) => {
let revealAuto = config.get<boolean | undefined | null>('file.autoReveal');
if (revealAuto !== undefined && revealAuto !== null) {
logger.error(
'`explorer.file.autoReveal` has been deprecated, please use explorer.file.reveal.auto instead of it',
);
} else {
revealAuto = config.get('file.reveal.auto');
}
return revealAuto;
};

export const getRevealWhenOpen = (
config: ExplorerConfig,
revealWhenOpenArg: boolean | undefined,
) => {
if (revealWhenOpenArg !== undefined) {
return revealWhenOpenArg;
}
/**
* @deprecated
*/
let revealWhenOpen: boolean | undefined | null = config.get(
'file.revealWhenOpen',
);
if (revealWhenOpen !== undefined && revealWhenOpen !== null) {
logger.error(
'`explorer.file.autoReveal` has been deprecated, please use explorer.file.reveal.whenOpen instead of it',
);
} else {
revealWhenOpen = config.get('file.reveal.whenOpen');
}
return revealWhenOpen;
return config.get('file.reveal.whenOpen');
};

export function buildExplorerConfig(
Expand Down
7 changes: 0 additions & 7 deletions src/icon/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,13 +102,6 @@ export async function loadIconsByConfig(
config: ExplorerConfig,
targets: IconTarget[],
) {
const enabledVimDevicons = config.get('icon.enableVimDevicons');
if (enabledVimDevicons) {
logger.error(
'The configuration `explorer.icon.enableVimDevicons` has been deprecated, please use `{"explorer.icon.enableNerdFont": true, "explorer.icon.source": "vim-devicons"}` instead of it',
);
return loadIcons('vim-devicons', targets);
}
const enabledNerdFont = config.get('icon.enableNerdfont');
if (!enabledNerdFont) {
return;
Expand Down
15 changes: 0 additions & 15 deletions src/source/sources/file/fileActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -742,21 +742,6 @@ export function loadFileActions(action: ActionSource<FileSource, FileNode>) {
},
);

action.addNodeAction(
'searchRecursive',
async ({ node }) => {
logger.error(
'searchRecursive action has been deprecated, please use "search:recursive" instead of it',
);
await file.searchByCocList(pathLib.dirname(node.fullpath), {
recursive: true,
noIgnore: false,
strict: false,
});
},
'search by coc-list recursively',
);

action.addNodeAction(
'toggleOnlyGitChange',
async () => {
Expand Down
23 changes: 5 additions & 18 deletions src/source/sources/file/fileSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import fs from 'fs';
import { homedir } from 'os';
import pathLib from 'path';
import { argOptions } from '../../../arg/argOptions';
import { getRevealAuto, getRevealWhenOpen } from '../../../config';
import { config, getRevealWhenOpen } from '../../../config';
import { diagnosticHighlights } from '../../../diagnostic/highlights';
import { onBufEnter } from '../../../events';
import { gitManager } from '../../../git/manager';
Expand All @@ -27,7 +27,7 @@ import {
} from '../../../util';
import type { RendererSource } from '../../../view/rendererSource';
import { ViewSource } from '../../../view/viewSource';
import { type BaseTreeNode, ExplorerSource } from '../../source';
import { ExplorerSource, type BaseTreeNode } from '../../source';
import { sourceManager } from '../../sourceManager';
import { fileArgOptions } from './argOptions';
import { loadFileActions } from './fileActions';
Expand Down Expand Up @@ -162,7 +162,7 @@ export class FileSource extends ExplorerSource<FileNode> {
}

async init() {
if (getRevealAuto(this.config)) {
if (config.get('file.reveal.auto')) {
this.disposables.push(
onBufEnter(async (bufnr) => {
if (bufnr === this.explorer.bufnr) {
Expand Down Expand Up @@ -215,20 +215,7 @@ export class FileSource extends ExplorerSource<FileNode> {
const { nvim } = this;
const escapePath = (await nvim.call('fnameescape', fullpath)) as string;
type CdCmd = Explorer['explorer.file.cdCommand'];
let cdCmd: CdCmd;
const tabCd = this.config.get<boolean | undefined | null>('file.tabCD');
if (tabCd !== undefined && tabCd !== null) {
logger.error(
'explorer.file.tabCD has been deprecated, please use explorer.file.cdCommand instead of it',
);
if (tabCd) {
cdCmd = 'tcd';
} else {
cdCmd = 'cd';
}
} else {
cdCmd = this.config.get<CdCmd>('file.cdCommand');
}
const cdCmd = this.config.get<CdCmd>('file.cdCommand');
if (cdCmd === 'tcd') {
if (workspace.isNvim || (await nvim.call('exists', [':tcd']))) {
await nvim.command(`tcd ${escapePath}`);
Expand All @@ -253,7 +240,7 @@ export class FileSource extends ExplorerSource<FileNode> {
const hasRevealPath = args.has(argOptions.reveal);

if (
getRevealAuto(this.config) ||
config.get('file.reveal.auto') ||
getRevealWhenOpen(this.config, this.explorer.argValues.revealWhenOpen) ||
hasRevealPath
) {
Expand Down
46 changes: 0 additions & 46 deletions src/util/function.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export * from './vim';
export * from './ui';
export * from './platform';
export * from './cli';
export * from './function';
export * from './uri';
export * from './color';
export * from './rx';
Expand Down

0 comments on commit 237f89d

Please sign in to comment.