From 85703c65b086368544847c3841b2dc9ead91b811 Mon Sep 17 00:00:00 2001 From: Druthi Polisetty Date: Mon, 26 Jun 2023 15:11:40 +0530 Subject: [PATCH] fix: Debugger shortcut is line deletion shortcut on the editor (#24725) ## Description fix: Debugger shortcut is line deletion shortcut on the editor #### PR fixes following issue(s) Fixes #22499 #### Type of change - Bug fix (non-breaking change which fixes an issue) ## Testing #### How Has This Been Tested? - [x] Manual #### Test Plan Checked keyboard shortcut behaviour on the editor > > #### Issues raised during DP testing none > > > ## Checklist: #### Dev activity - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] PR is being merged under a feature flag #### QA activity: - [ ] [Speedbreak features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-) have been covered - [ ] Test plan covers all impacted features and [areas of interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-) - [ ] Test plan has been peer reviewed by project stakeholders and other QA members - [x] Manually tested functionality on DP - [ ] We had an implementation alignment call with stakeholders post QA Round 2 - [ ] Cypress test cases have been added and approved by SDET/manual QA - [ ] Added `Test Plan Approved` label after Cypress tests were reviewed - [ ] Added `Test Plan Approved` label after JUnit tests were reviewed --- .../src/components/editorComponents/CodeEditor/index.tsx | 4 ++++ .../editorComponents/CodeEditor/utils/deleteLine.ts | 7 +++++++ .../CodeEditor/utils/keyboardShortcutConstants.ts | 6 ++++++ 3 files changed, 17 insertions(+) create mode 100644 app/client/src/components/editorComponents/CodeEditor/utils/deleteLine.ts diff --git a/app/client/src/components/editorComponents/CodeEditor/index.tsx b/app/client/src/components/editorComponents/CodeEditor/index.tsx index bc2bd9095a..33071e9534 100644 --- a/app/client/src/components/editorComponents/CodeEditor/index.tsx +++ b/app/client/src/components/editorComponents/CodeEditor/index.tsx @@ -157,6 +157,7 @@ import { debug } from "loglevel"; import { PeekOverlayExpressionIdentifier, SourceType } from "@shared/ast"; import type { MultiplexingModeConfig } from "components/editorComponents/CodeEditor/modes"; import { MULTIPLEXING_MODE_CONFIGS } from "components/editorComponents/CodeEditor/modes"; +import { getDeleteLineShortcut } from "./utils/deleteLine"; type ReduxStateProps = ReturnType; type ReduxDispatchProps = ReturnType; @@ -379,6 +380,9 @@ class CodeEditor extends Component { saveAndAutoIndentCode(editor); AnalyticsUtil.logEvent("PRETTIFY_AND_SAVE_KEYBOARD_SHORTCUT"); }, + [getDeleteLineShortcut()]: () => { + return; + }, }; if (this.props.tabBehaviour === TabBehaviour.INPUT) { diff --git a/app/client/src/components/editorComponents/CodeEditor/utils/deleteLine.ts b/app/client/src/components/editorComponents/CodeEditor/utils/deleteLine.ts new file mode 100644 index 0000000000..faa4640d64 --- /dev/null +++ b/app/client/src/components/editorComponents/CodeEditor/utils/deleteLine.ts @@ -0,0 +1,7 @@ +import { getPlatformOS } from "utils/helpers"; +import { KEYBOARD_SHORTCUTS_BY_PLATFORM } from "./keyboardShortcutConstants"; + +export const getDeleteLineShortcut = () => { + const platformOS = getPlatformOS() || "default"; + return KEYBOARD_SHORTCUTS_BY_PLATFORM[platformOS].deleteLine; +}; diff --git a/app/client/src/components/editorComponents/CodeEditor/utils/keyboardShortcutConstants.ts b/app/client/src/components/editorComponents/CodeEditor/utils/keyboardShortcutConstants.ts index 98bb6d42d4..60141b6d63 100644 --- a/app/client/src/components/editorComponents/CodeEditor/utils/keyboardShortcutConstants.ts +++ b/app/client/src/components/editorComponents/CodeEditor/utils/keyboardShortcutConstants.ts @@ -7,6 +7,7 @@ export const KEYBOARD_SHORTCUTS_BY_PLATFORM = { autoIndentShortcut: "Shift-Cmd-P", autoIndentShortcutText: "Shift + Cmd + P", codeComment: "Cmd-/", + deleteLine: "Cmd-D", }, [PLATFORM_OS.IOS]: { saveAndAutoIndent: "Cmd-S", @@ -14,6 +15,7 @@ export const KEYBOARD_SHORTCUTS_BY_PLATFORM = { autoIndentShortcut: "Shift-Cmd-P", autoIndentShortcutText: "Shift + Cmd + P", codeComment: "Cmd-/", + deleteLine: "Cmd-D", }, [PLATFORM_OS.WINDOWS]: { saveAndAutoIndent: "Ctrl-S", @@ -21,6 +23,7 @@ export const KEYBOARD_SHORTCUTS_BY_PLATFORM = { autoIndentShortcut: "Shift-Alt-F", autoIndentShortcutText: "Shift + Alt + F", codeComment: "Ctrl-/", + deleteLine: "Ctrl-D", }, [PLATFORM_OS.ANDROID]: { saveAndAutoIndent: "Ctrl-S", @@ -28,6 +31,7 @@ export const KEYBOARD_SHORTCUTS_BY_PLATFORM = { autoIndentShortcut: "Shift-Alt-F", autoIndentShortcutText: "Shift + Alt + F", codeComment: "Ctrl-/", + deleteLine: "Ctrl-D", }, [PLATFORM_OS.LINUX]: { saveAndAutoIndent: "Ctrl-S", @@ -35,6 +39,7 @@ export const KEYBOARD_SHORTCUTS_BY_PLATFORM = { autoIndentShortcut: "Shift-Ctrl-I", autoIndentShortcutText: "Shift + Ctrl + I", codeComment: "Ctrl-/", + deleteLine: "Ctrl-D", }, default: { saveAndAutoIndent: "Ctrl-S", @@ -42,5 +47,6 @@ export const KEYBOARD_SHORTCUTS_BY_PLATFORM = { autoIndentShortcut: "Shift-Alt-F", autoIndentShortcutText: "Shift + Alt + F", codeComment: "Ctrl-/", + deleteLine: "Ctrl-D", }, };