快捷键循环转换支持过滤用户配置的禁用格式 (disableFormat)
This commit is contained in:
		@@ -3,6 +3,7 @@ import { EOL } from "../type-definition/EOLType";
 | 
				
			|||||||
import { cyclicConvertCaseOrder } from "../type-definition/SupportCaseType";
 | 
					import { cyclicConvertCaseOrder } from "../type-definition/SupportCaseType";
 | 
				
			||||||
import { caseConversion } from "./conversion";
 | 
					import { caseConversion } from "./conversion";
 | 
				
			||||||
import { isStringArrayEqual, stringListArrayDuplicateRemoval } from './utils';
 | 
					import { isStringArrayEqual, stringListArrayDuplicateRemoval } from './utils';
 | 
				
			||||||
 | 
					import { getUserConfigurations } from './user-configuration';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
interface UserSelection {
 | 
					interface UserSelection {
 | 
				
			||||||
    currentEol: EOL
 | 
					    currentEol: EOL
 | 
				
			||||||
@@ -64,16 +65,25 @@ function lazyConvert() {
 | 
				
			|||||||
        return;
 | 
					        return;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    // 获取用户配置
 | 
				
			||||||
 | 
					    const disableFormatList = getUserConfigurations('disableFormat');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    const textList = userSelection.currentSelectionsText;
 | 
					    const textList = userSelection.currentSelectionsText;
 | 
				
			||||||
    // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));
 | 
					    // vscode.window.showInformationMessage('lazyConvert' + textList.join('\n'));
 | 
				
			||||||
    const eol = userSelection.currentEol;
 | 
					    const eol = userSelection.currentEol;
 | 
				
			||||||
    const conversionsTarget: Array<string[]> = [textList];
 | 
					    const conversionsTarget: Array<string[]> = [textList];
 | 
				
			||||||
    for (const cyclicConvertCase of cyclicConvertCaseOrder) {
 | 
					    for (const cyclicConvertCase of cyclicConvertCaseOrder) {
 | 
				
			||||||
 | 
					        // issue: #1 https://github.com/coder-xiaomo/variable-conversion-vscode-extension/issues/1
 | 
				
			||||||
 | 
					        // 跳过禁用的目标格式
 | 
				
			||||||
 | 
					        if (disableFormatList.includes(cyclicConvertCase.settingsKey)) {
 | 
				
			||||||
 | 
					            continue;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // 每一个类型
 | 
					        // 每一个类型
 | 
				
			||||||
        const conversionsTargetItem: string[] = [];
 | 
					        const conversionsTargetItem: string[] = [];
 | 
				
			||||||
        for (const line of textList) {
 | 
					        for (const line of textList) {
 | 
				
			||||||
            // 选中区块的每一行
 | 
					            // 选中区块的每一行
 | 
				
			||||||
            const conversionResult: string = caseConversion(cyclicConvertCase, line, eol);
 | 
					            const conversionResult: string = caseConversion(cyclicConvertCase.type, line, eol);
 | 
				
			||||||
            conversionsTargetItem.push(conversionResult);
 | 
					            conversionsTargetItem.push(conversionResult);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        conversionsTarget.push(conversionsTargetItem);
 | 
					        conversionsTarget.push(conversionsTargetItem);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -544,33 +544,38 @@ export const quickPickSupportCases: Array<QuickPickSupportCaseItem> = [
 | 
				
			|||||||
    },
 | 
					    },
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					export interface CyclicConvertCaseOrderItem {
 | 
				
			||||||
 | 
					    type: SupportCase,
 | 
				
			||||||
 | 
					    settingsKey: string,
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 * 通过快捷键循环转换的顺序
 | 
					 * 通过快捷键循环转换的顺序
 | 
				
			||||||
 * @since 2024-04-08
 | 
					 * @since 2024-04-08
 | 
				
			||||||
 */
 | 
					 */
 | 
				
			||||||
export const cyclicConvertCaseOrder = [
 | 
					export const cyclicConvertCaseOrder: Array<CyclicConvertCaseOrderItem> = [
 | 
				
			||||||
    SupportCase.CAMEL_CASE,
 | 
					    { type: SupportCase.CAMEL_CASE, settingsKey: 'camel_case' },
 | 
				
			||||||
    SupportCase.SNAKE_CASE,
 | 
					    { type: SupportCase.SNAKE_CASE, settingsKey: 'snake_case' },
 | 
				
			||||||
    SupportCase.PASCAL_CASE,
 | 
					    { type: SupportCase.PASCAL_CASE, settingsKey: 'pascal_case' },
 | 
				
			||||||
    SupportCase.KEBAB_CASE,
 | 
					    { type: SupportCase.KEBAB_CASE, settingsKey: 'kebab_case' },
 | 
				
			||||||
    SupportCase.SPACE_CASE,
 | 
					    { type: SupportCase.SPACE_CASE, settingsKey: 'space_case' },
 | 
				
			||||||
    SupportCase.DOT_CASE,
 | 
					    { type: SupportCase.DOT_CASE, settingsKey: 'dot_case' },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SupportCase.SNAKE_UPPER_CASE,
 | 
					    { type: SupportCase.SNAKE_UPPER_CASE, settingsKey: 'snake_upper_case' },
 | 
				
			||||||
    SupportCase.KEBAB_UPPER_CASE,
 | 
					    { type: SupportCase.KEBAB_UPPER_CASE, settingsKey: 'kebab_upper_case' },
 | 
				
			||||||
    SupportCase.SPACE_UPPER_CASE,
 | 
					    { type: SupportCase.SPACE_UPPER_CASE, settingsKey: 'space_upper_case' },
 | 
				
			||||||
    SupportCase.DOT_UPPER_CASE,
 | 
					    { type: SupportCase.DOT_UPPER_CASE, settingsKey: 'dot_upper_case' },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SupportCase.SNAKE_PASCAL_CASE,
 | 
					    { type: SupportCase.SNAKE_PASCAL_CASE, settingsKey: 'snake_pascal_case' },
 | 
				
			||||||
    SupportCase.KEBAB_PASCAL_CASE,
 | 
					    { type: SupportCase.KEBAB_PASCAL_CASE, settingsKey: 'kebab_pascal_case' },
 | 
				
			||||||
    SupportCase.SPACE_PASCAL_CASE,
 | 
					    { type: SupportCase.SPACE_PASCAL_CASE, settingsKey: 'space_pascal_case' },
 | 
				
			||||||
    SupportCase.DOT_PASCAL_CASE,
 | 
					    { type: SupportCase.DOT_PASCAL_CASE, settingsKey: 'dot_pascal_case' },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SupportCase.SNAKE_CAMEL_CASE,
 | 
					    { type: SupportCase.SNAKE_CAMEL_CASE, settingsKey: 'snake_camel_case' },
 | 
				
			||||||
    SupportCase.KEBAB_CAMEL_CASE,
 | 
					    { type: SupportCase.KEBAB_CAMEL_CASE, settingsKey: 'kebab_camel_case' },
 | 
				
			||||||
    SupportCase.SPACE_CAMEL_CASE,
 | 
					    { type: SupportCase.SPACE_CAMEL_CASE, settingsKey: 'space_camel_case' },
 | 
				
			||||||
    SupportCase.DOT_CAMEL_CASE,
 | 
					    { type: SupportCase.DOT_CAMEL_CASE, settingsKey: 'dot_camel_case' },
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SupportCase.LOWER_CASE,
 | 
					    { type: SupportCase.LOWER_CASE, settingsKey: 'lower_case' },
 | 
				
			||||||
    SupportCase.UPPER_CASE,
 | 
					    { type: SupportCase.UPPER_CASE, settingsKey: 'upper_case' },
 | 
				
			||||||
];
 | 
					];
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user