This commit is contained in:
Tyler James Leonhardt 2023-12-14 07:23:45 -08:00 коммит произвёл GitHub
Родитель 47f9ab83f3
Коммит 97fb0d5581
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 3372 добавлений и 401 удалений

Просмотреть файл

@ -23,6 +23,10 @@ parameters:
extends:
template: azure-pipelines/extension/stable.yml@templates
parameters:
publishExtension: ${{ parameters.publishExtension }}
l10nSourcePaths: ./src
buildSteps:
- script: npm ci
displayName: Install dependencies
@ -39,4 +43,3 @@ extends:
- 'stbatt@microsoft.com'
- 'lszomoru@microsoft.com'
publishExtension: ${{ parameters.publishExtension }}

3674
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -2,11 +2,11 @@
"name": "sublime-keybindings",
"displayName": "Sublime Text Keymap and Settings Importer",
"description": "Import Sublime Text settings and keybindings into VS Code.",
"version": "4.0.10",
"version": "4.1.10",
"publisher": "ms-vscode",
"license": "SEE LICENSE IN LICENSE.md",
"engines": {
"vscode": "^1.53.0"
"vscode": "^1.75.0"
},
"categories": [
"Keymaps"
@ -22,6 +22,7 @@
],
"main": "./dist/extension.js",
"browser": "./dist/web/extension.js",
"l10n": "./l10n",
"preview": false,
"extensionKind": [
"ui",
@ -51,7 +52,7 @@
"@types/glob": "^7.1.3",
"@types/mocha": "^8.2.2",
"@types/node": "^12.12.0",
"@types/vscode": "^1.53.0",
"@types/vscode": "^1.75.0",
"@types/relaxed-json": "^1.0.0",
"glob": "^7.1.6",
"mocha": "^10.2.0",
@ -59,8 +60,8 @@
"typescript": "^4.2.3",
"vscode-test": "^1.5.2",
"ts-loader": "^8.1.0",
"webpack": "^5.30.0",
"webpack-cli": "^4.6.0"
"webpack": "^5.89.0",
"webpack-cli": "^5.1.4"
},
"dependencies": {
"relaxed-json": "^1.0.3"
@ -77,7 +78,8 @@
"commands": [
{
"command": "extension.importFromSublime",
"title": "Sublime Text Keymap: Import Sublime Text Settings"
"title": "%extension.importFromSublime.title%",
"category": "%extension.category%"
}
],
"keybindings": [

4
package.nls.json Normal file
Просмотреть файл

@ -0,0 +1,4 @@
{
"extension.importFromSublime.title": "Import Sublime Text Settings",
"extension.category": "Sublime Text Keymap"
}

Просмотреть файл

@ -18,8 +18,14 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}
async function showPrompt(): Promise<void> {
const answer: string | undefined = await vscode.window.showInformationMessage('Would you like to customize VS Code to behave more like Sublime Text?', 'Yes', 'No');
if (answer && answer === 'Yes') {
const yes = vscode.l10n.t('Yes');
const no = vscode.l10n.t('No');
const answer: string | undefined = await vscode.window.showInformationMessage(
vscode.l10n.t('Would you like to customize VS Code to behave more like Sublime Text?'),
yes,
no,
);
if (answer && answer === yes) {
start();
}
}
@ -34,7 +40,7 @@ async function start(): Promise<void> {
await vscode.commands.executeCommand('workbench.action.openGlobalSettings');
}
} else {
vscode.window.showInformationMessage('Nothing to import. All settings have already been imported');
vscode.window.showInformationMessage(vscode.l10n.t('Nothing to import. All settings have already been imported'));
}
}
}
@ -52,24 +58,38 @@ async function getSublimeFolderPath(): Promise<string | undefined> {
if (sublimeSettingsPath) {
return sublimeSettingsPath.fsPath;
}
return await browsePrompt(`No Sublime settings file found at the default location: ${path.join(sublimeFolderFinder.getOSDefaultPaths()[0], sublimeFolderFinder.sublimeSettingsFilename)} `);
return await browsePrompt(
vscode.l10n.t(
'No Sublime settings file found at the default location: {0}',
path.join(sublimeFolderFinder.getOSDefaultPaths()[0], sublimeFolderFinder.sublimeSettingsFilename)
)
);
}
async function browsePrompt(msg: string): Promise<string | undefined> {
const result = await vscode.window.showInformationMessage(msg, 'Browse...');
if (result) {
const sublimeSettingsFiles = await vscode.window.showOpenDialog({ canSelectFiles: true });
if (sublimeSettingsFiles && sublimeSettingsFiles.length) {
const filePath = sublimeSettingsFiles[0].fsPath;
const isValidFilePath = await validate(filePath);
if (isValidFilePath) {
return filePath;
} else {
vscode.window.showErrorMessage(`Could not find ${sublimeFolderFinder.sublimeSettingsFilename} at ${sublimeSettingsFiles[0].fsPath} `);
}
}
const result = await vscode.window.showInformationMessage(msg, vscode.l10n.t('Browse...'));
if (!result) {
return undefined;
}
const sublimeSettingsFiles = await vscode.window.showOpenDialog({ canSelectFiles: true });
if (!sublimeSettingsFiles || !sublimeSettingsFiles.length) {
return undefined;
}
const filePath = sublimeSettingsFiles[0].fsPath;
const isValidFilePath = await validate(filePath);
if (isValidFilePath) {
return filePath;
} else {
vscode.window.showErrorMessage(
vscode.l10n.t({
message: 'Could not find {0} at {1}',
args: [sublimeFolderFinder.sublimeSettingsFilename, sublimeSettingsFiles[0].fsPath],
comment: ['{0} is a filename, {1} is a path']
})
);
return undefined;
}
return undefined;
}
function validate(settingsFilePath: string): boolean {
@ -109,7 +129,7 @@ function setting2QuickPickItem(setting: VscodeSetting, sublimeName?: string): IS
const icons = { exclamationPoint: '$(issue-opened)', arrowRight: '$(arrow-right)' }; // stored in var because auto-format adds spaces to hypens
return {
detail: setting.overwritesValue
? `${icons.exclamationPoint} Overwrites existing value: '${setting.oldValue}' with '${setting.value}'`
? icons.exclamationPoint + ' ' + vscode.l10n.t(`Overwrites existing value: '{0}' with '{1}'`, setting.oldValue, setting.value)
: '',
label: sublimeName
? `${sublimeName} ${icons.arrowRight} ${setting.name}`
@ -122,7 +142,7 @@ function setting2QuickPickItem(setting: VscodeSetting, sublimeName?: string): IS
async function importSettings(settings: ISetting[]): Promise<void> {
return vscode.window.withProgress({
location: vscode.ProgressLocation.Notification,
title: 'Importing Settings',
title: vscode.l10n.t('Importing Settings'),
}, async (progress) => {
progress.report({ increment: 0 });
const incrementSize = 100.0 / settings.length;
@ -131,7 +151,7 @@ async function importSettings(settings: ISetting[]): Promise<void> {
try {
await config.update(setting.name, setting.value, vscode.ConfigurationTarget.Global);
progress.report({ increment: incrementSize, message: setting.name });
} catch (e) {
} catch (e: any) {
vscode.window.showErrorMessage(e.message);
return;
}

Просмотреть файл

@ -25,7 +25,7 @@ export class Mapper {
try {
parsedSublimeSettings = rjson.parse(sublimeSettings);
} catch (e) {
vscode.window.showErrorMessage('The sublime settings file could not be parsed. Please check if it contains syntax errors.');
vscode.window.showErrorMessage(vscode.l10n.t('The sublime settings file could not be parsed. Please check if it contains syntax errors.'));
throw (e);
}
return this.mapAllSettings(settingsMappings, parsedSublimeSettings);
@ -95,7 +95,7 @@ export class Mapper {
const configTest = this.checkWithExistingSettings(defaultSetting, config);
if (configTest.alreadyExists) {
settings.alreadyExisting.push(new MappedSetting({ name: 'Default Setting', value: '' }, defaultSetting));
settings.alreadyExisting.push(new MappedSetting({ name: vscode.l10n.t('Default Setting'), value: '' }, defaultSetting));
} else {
if (configTest.existingValue) {
defaultSetting.markAsOverride(configTest.existingValue);
@ -125,7 +125,13 @@ export class Mapper {
} else if (typeof mappedValue === 'object') {
const obj = mappedValue[sublimeSetting.value];
if (!obj) {
vscode.window.showErrorMessage(`Failed to parse setting: '${sublimeSetting.name}: ${sublimeSetting.value}'. Please check if it contains syntax errors`);
vscode.window.showErrorMessage(vscode.l10n.t(
{
message: "Failed to parse setting: '{0}: {1}'. Please check if it contains syntax errors",
args: [sublimeSetting.name, sublimeSetting.value],
comment: ["{0} is the name of the setting, {1} is the value of the setting"]
}
));
return undefined;
}
const keys = Object.keys(obj);

Просмотреть файл

@ -3,6 +3,6 @@ import * as vscode from 'vscode';
export async function activate(context: vscode.ExtensionContext): Promise<void> {
context.subscriptions.push(vscode.commands.registerCommand('extension.importFromSublime', () => {
vscode.window.showWarningMessage('Importing from local Sublime settings is currently only possible when running in the desktop.', { modal: true })
vscode.window.showWarningMessage(vscode.l10n.t('Importing from local Sublime settings is currently only possible when running in the desktop.'), { modal: true })
}));
}
}