添加路径转换右键菜单;实现路径转换 QuickPick 快速选择
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { EOL } from "../../types/EOLType";
|
||||
import { SupportPathFormat } from "./types/SupportPathFormatType";
|
||||
import { TransformTextResult } from '../../types/TransformTextResultType';
|
||||
|
||||
/** / */
|
||||
const LEFT_SLASH = '/';
|
||||
@@ -8,7 +9,7 @@ const RIGHT_SLASH = '\\';
|
||||
/** \\ */
|
||||
const DOUBLE_RIGHT_SLASH = '\\\\';
|
||||
|
||||
export function pathConversion(targetPathType: SupportPathFormat, input: string, eol: EOL): string {
|
||||
export function pathConversion(targetPathType: SupportPathFormat, input: string, eol: EOL, cutText: Array<TransformTextResult> | undefined = undefined): string {
|
||||
let resultPath;
|
||||
|
||||
let isSeperator = false;
|
||||
|
@@ -67,7 +67,7 @@ function lazyConvert() {
|
||||
|
||||
// 获取用户配置
|
||||
// TODO
|
||||
// const disableFormatList = getUserConfigurations<Array<string>>('disableFormat') || [];
|
||||
// const disablePathFormatList = getUserConfigurations<Array<string>>('disablePathFormat') || [];
|
||||
|
||||
const textList = userSelection.currentSelectionsText;
|
||||
// vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));
|
||||
@@ -76,7 +76,7 @@ function lazyConvert() {
|
||||
for (const cyclicConvertCase of cyclicConvertPathOrder) {
|
||||
// 跳过禁用的目标格式
|
||||
// TODO
|
||||
// if (disableFormatList.includes(cyclicConvertCase.settingsKey)) {
|
||||
// if (disablePathFormatList.includes(cyclicConvertCase.settingsKey)) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
|
@@ -6,7 +6,7 @@
|
||||
export enum SupportPathFormat {
|
||||
|
||||
/**
|
||||
* Windows 格式
|
||||
* Windows 风格
|
||||
*
|
||||
* @alias: windows / Windows
|
||||
* @since 2024-12-07
|
||||
@@ -14,7 +14,7 @@ export enum SupportPathFormat {
|
||||
Windows,
|
||||
|
||||
/**
|
||||
* Unix 格式
|
||||
* Unix 风格
|
||||
*
|
||||
* @alias: unix / Unix
|
||||
* @since 2024-12-07
|
||||
@@ -22,6 +22,67 @@ export enum SupportPathFormat {
|
||||
Unix,
|
||||
};
|
||||
|
||||
const keyword = {
|
||||
windows: [
|
||||
'Windows', 'win',
|
||||
],
|
||||
unix: [
|
||||
'Unix',
|
||||
'Linux',
|
||||
'macOS',
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* 接管的变量转换命令
|
||||
*
|
||||
* @since 2024-12-14
|
||||
*/
|
||||
export const commands: Array<{ command: string; targetCase: SupportPathFormat; settingsKey: string }> = [
|
||||
{
|
||||
command: 'variable-conversion.pathFormat.toWindowsStyle',
|
||||
targetCase: SupportPathFormat.Windows,
|
||||
settingsKey: 'windows_style'
|
||||
},
|
||||
{
|
||||
command: 'variable-conversion.pathFormat.toUnixStyle',
|
||||
targetCase: SupportPathFormat.Unix,
|
||||
settingsKey: 'unix_style'
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* @since 2024-12-14
|
||||
*/
|
||||
export interface QuickPickSupportCaseItem {
|
||||
type: SupportPathFormat,
|
||||
name: string,
|
||||
shortName: string,
|
||||
keyword: string[],
|
||||
settingsKey: string,
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有支持的路径风格
|
||||
* @since 2024-12-14
|
||||
*/
|
||||
export const quickPickSupportCases: Array<QuickPickSupportCaseItem> = [
|
||||
{
|
||||
type: SupportPathFormat.Windows,
|
||||
name: 'Microsoft Windows 风格',
|
||||
shortName: 'Windows 风格',
|
||||
keyword: keyword.windows,
|
||||
settingsKey: 'windows_style',
|
||||
},
|
||||
{
|
||||
type: SupportPathFormat.Unix,
|
||||
name: 'Unix / 类 Unix 风格 (Linux, macOS, ...)',
|
||||
shortName: 'Unix 风格',
|
||||
keyword: keyword.unix,
|
||||
settingsKey: 'unix_style',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* @since 2024-12-14
|
||||
*/
|
||||
|
Reference in New Issue
Block a user