From 433be79dd62beb6fa046f9e9093cedbb44cc4299 Mon Sep 17 00:00:00 2001 From: George Garside Date: Sun, 28 Apr 2024 14:06:11 +0100 Subject: [PATCH] Complete current statement with semicolon if JS and configured Fixes #65 by inserting a semicolon at the end of the line if language is JavaScript (or TypeScript) and semicolons are configured as required using the existing `javascript.format.semicolons` configuration option in the JavaScript extension. --- README.md | 2 +- package.json | 26 +++++++++++++++++++++++++- src/package-with-comment.json | 26 +++++++++++++++++++++++++- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 6d3c892..5493206 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ ctrl+space | ctrl+space | Basic code completion (the name of any class, method o ctrl+shift+space | ctrl+shift+space | Smart code completion (filters the list of methods and variables by expected type) | N/A enter | enter | Choose Lookup Item | ✅ tab | tab | Choose Lookup Item Replace | ✅ -ctrl+shift+enter | cmd+shift+enter | Complete statement | ✅ +ctrl+shift+enter | cmd+shift+enter | Complete Current Statement | ✅ ctrl+p | cmd+p | Parameter info (within method call arguments) | ✅ ctrl+q | ctrl+j | Quick documentation lookup | ✅ N/A | f1 | Quick documentation lookup | ✅ diff --git a/package.json b/package.json index 27faaa3..cb81b87 100644 --- a/package.json +++ b/package.json @@ -109,12 +109,36 @@ "when": "suggestWidgetVisible && textInputFocus", "intellij": "Choose Lookup Item Replace" }, + { + "key": "ctrl+shift+enter", + "mac": "cmd+shift+enter", + "command": "runCommands", + "args": { + "commands": [ + "acceptSelectedSuggestion", + { + "command": "cursorMove", + "args": { + "to": "wrappedLineEnd" + } + }, + { + "command": "editor.action.insertSnippet", + "args": { + "snippet": ";" + } + } + ] + }, + "when": "suggestWidgetVisible && textInputFocus && (resourceLangId == 'javascript' || resourceLangId == 'typescript') && config.javascript.format.semicolons == 'insert'", + "intellij": "Complete Current Statement" + }, { "key": "ctrl+shift+enter", "mac": "cmd+shift+enter", "command": "acceptSelectedSuggestion", "when": "suggestWidgetVisible && textInputFocus", - "intellij": "Complete statement" + "intellij": "Complete Current Statement" }, { "key": "ctrl+p", diff --git a/src/package-with-comment.json b/src/package-with-comment.json index efa885f..d3884b9 100644 --- a/src/package-with-comment.json +++ b/src/package-with-comment.json @@ -128,12 +128,36 @@ "when": "suggestWidgetVisible && textInputFocus", "intellij": "Choose Lookup Item Replace" }, + { + "key": "ctrl+shift+enter", + "mac": "cmd+shift+enter", + "command": "runCommands", + "args": { + "commands": [ + "acceptSelectedSuggestion", + { + "command": "cursorMove", + "args": { + "to": "wrappedLineEnd" + } + }, + { + "command": "editor.action.insertSnippet", + "args": { + "snippet": ";" + } + } + ] + }, + "when": "suggestWidgetVisible && textInputFocus && (resourceLangId == 'javascript' || resourceLangId == 'typescript') && config.javascript.format.semicolons == 'insert'", + "intellij": "Complete Current Statement" + }, { "key": "ctrl+shift+enter", "mac": "cmd+shift+enter", "command": "acceptSelectedSuggestion", "when": "suggestWidgetVisible && textInputFocus", - "intellij": "Complete statement" + "intellij": "Complete Current Statement" }, { "key": "ctrl+p",