1
0
Code Issues Pull Requests Packages Projects Releases Wiki Activity GitHub Gitee

添加路径转换右键菜单;实现路径转换 QuickPick 快速选择

This commit is contained in:
2024-12-14 23:56:37 +08:00
parent 948976f7ee
commit 8d19f9e0ba
11 changed files with 466 additions and 38 deletions

View File

@@ -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;

View File

@@ -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;
// }

View File

@@ -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
*/