From d66524617a809e3eaf084cec0d8cfca6db6340b3 Mon Sep 17 00:00:00 2001 From: Robin Gustafsson Date: Thu, 13 May 2021 15:25:47 +0200 Subject: [PATCH] Add "Unwrap Comment / Text" command Unwrapping is possible with the "Rewrap/Unwrap Text At Column...", but requires a second step of manual input then. Adding a dedicated unwrap command avoids the prompt and makes it possible to keybind the action. --- docs/keybindings-vscode.md | 8 ++++++++ vscode/package.json | 4 ++++ vscode/src/Extension.ts | 7 +++++++ 3 files changed, 19 insertions(+) diff --git a/docs/keybindings-vscode.md b/docs/keybindings-vscode.md index ce0e757..cecdf38 100644 --- a/docs/keybindings-vscode.md +++ b/docs/keybindings-vscode.md @@ -16,6 +16,14 @@ To add a keybinding for the **Wrap Comment / Text at column...** command, use it } ``` +### Unwrap command ### +To add a keybinding for the **Unwrap Comment / Text** command, use its `rewrap.unwrapComment` id: +```json5 +{ + "key": "alt+shift+q", "command": "rewrap.unwrapComment" +} +``` + ### Auto-wrap command ### To add a keybinding for the auto-wrap toggle, use the command ID `rewrap.toggleAutoWrap`. diff --git a/vscode/package.json b/vscode/package.json index 866f5bc..15de71e 100644 --- a/vscode/package.json +++ b/vscode/package.json @@ -46,6 +46,10 @@ "command": "rewrap.rewrapComment", "title": "Rewrap Comment / Text" }, + { + "command": "rewrap.unwrapComment", + "title": "Unwrap Comment / Text" + }, { "command": "rewrap.rewrapCommentAt", "title": "Rewrap/Unwrap Text At Column..." diff --git a/vscode/src/Extension.ts b/vscode/src/Extension.ts index c5b669f..6b19889 100644 --- a/vscode/src/Extension.ts +++ b/vscode/src/Extension.ts @@ -13,6 +13,7 @@ async function activate(context) { // Register the commands context.subscriptions.push ( commands.registerTextEditorCommand('rewrap.rewrapComment', rewrapCommentCommand) + , commands.registerTextEditorCommand('rewrap.unwrapComment', unwrapCommentCommand) , commands.registerTextEditorCommand('rewrap.rewrapCommentAt', rewrapCommentAtCommand) , commands.registerTextEditorCommand('rewrap.toggleAutoWrap', autoWrap.editorToggle) ) @@ -23,6 +24,12 @@ async function activate(context) { doWrap(editor).then(() => saveDocState(getDocState(editor))) } + /** Unwrap command */ + function unwrapCommentCommand(editor) + { + doWrap(editor, 0).then(() => saveDocState(getDocState(editor))) + } + let customWrappingColumn = 0; /** Does a rewrap, but first prompts for a custom wrapping column to use. */ async function rewrapCommentAtCommand(editor)