diff --git a/package-lock.json b/package-lock.json index aa009ef..a2c8346 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "devDependencies": { "@types/mocha": "^10.0.6", "@types/node": "20.x", - "@types/vscode": "^1.90.0", + "@types/vscode": "^1.0.0", "@typescript-eslint/eslint-plugin": "^7.11.0", "@typescript-eslint/parser": "^7.11.0", "@vscode/test-cli": "^0.0.9", @@ -22,7 +22,7 @@ "webpack-cli": "^5.1.4" }, "engines": { - "vscode": "^1.6.0" + "vscode": "^1.0.0" }, "funding": { "url": "https://ko-fi.com/fcmam5" diff --git a/package.json b/package.json index 6c24aaf..40cba63 100644 --- a/package.json +++ b/package.json @@ -30,11 +30,11 @@ "commands": [ { "command": "nimiro.formatNumber", - "title": "Nimiro: Format" + "title": "Nimiro: Enter number to format" }, { "command": "nimiro.formatNumberKbd", - "title": "Nimiro format on keybindings pressed" + "title": "Nimiro: format selected number" } ], "keybindings": [ @@ -57,7 +57,7 @@ "test": "vscode-test" }, "devDependencies": { - "@types/vscode": "^1.90.0", + "@types/vscode": "^1.0.0", "@types/mocha": "^10.0.6", "@types/node": "20.x", "@typescript-eslint/eslint-plugin": "^7.11.0", diff --git a/src/extension.ts b/src/extension.ts index 4a870e9..c05b266 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -3,6 +3,21 @@ import * as vscode from "vscode"; import { formatNumberWithSpaces, isNumber } from "./utils"; +function showFormattedNumber() { + const editor = vscode.window.activeTextEditor; + if (editor) { + const document = editor.document; + const selection = editor.selection; + const selectedText = document.getText(selection); + + if (isNumber(selectedText)) { + vscode.window.showInformationMessage( + formatNumberWithSpaces(selectedText) + ); + } + } +} + export function activate(context: vscode.ExtensionContext) { const cmdWithInput = vscode.commands.registerCommand( "nimiro.formatNumber", @@ -18,24 +33,10 @@ export function activate(context: vscode.ExtensionContext) { const cmdWithKbd = vscode.commands.registerCommand( "nimiro.formatNumberKbd", - async () => { - const editor = vscode.window.activeTextEditor; - if (editor) { - const document = editor.document; - const selection = editor.selection; - const selectedText = document.getText(selection); - - if (isNumber(selectedText)) { - vscode.window.showInformationMessage( - formatNumberWithSpaces(selectedText) - ); - } - } - } + showFormattedNumber ); - context.subscriptions.push(cmdWithInput); - context.subscriptions.push(cmdWithKbd); + context.subscriptions.push(cmdWithKbd, cmdWithInput); } // This method is called when your extension is deactivated