From 84095a41838451db15a70ef7024f22d073ed81be Mon Sep 17 00:00:00 2001 From: Sanjai Kumar <84461672+sanjai0py@users.noreply.github.com> Date: Wed, 20 Nov 2024 18:14:37 +0530 Subject: [PATCH] fix/ Script execution is prevented by line comments (#3462) * refactor: simplify mode settings and update comment toggle functionality --------- Co-authored-by: Anoop M D --- .../src/components/CodeEditor/index.js | 28 ++----------------- 1 file changed, 2 insertions(+), 26 deletions(-) diff --git a/packages/bruno-app/src/components/CodeEditor/index.js b/packages/bruno-app/src/components/CodeEditor/index.js index 2994b5448..aa0238ef0 100644 --- a/packages/bruno-app/src/components/CodeEditor/index.js +++ b/packages/bruno-app/src/components/CodeEditor/index.js @@ -190,32 +190,8 @@ export default class CodeEditor extends React.Component { 'Cmd-Y': 'foldAll', 'Ctrl-I': 'unfoldAll', 'Cmd-I': 'unfoldAll', - 'Cmd-/': (cm) => { - // comment/uncomment every selected line(s) - const selections = cm.listSelections(); - selections.forEach((range) => { - for (let i = range.from().line; i <= range.to().line; i++) { - const selectedLine = cm.getLine(i); - // if commented line, remove comment - if (selectedLine.trim().startsWith('//')) { - cm.replaceRange( - selectedLine.replace(/^(\s*)\/\/\s?/, '$1'), - { line: i, ch: 0 }, - { line: i, ch: selectedLine.length } - ); - continue; - } - // otherwise add comment - cm.replaceRange( - selectedLine.search(/\S|$/) >= TAB_SIZE - ? ' '.repeat(TAB_SIZE) + '// ' + selectedLine.trim() - : '// ' + selectedLine, - { line: i, ch: 0 }, - { line: i, ch: selectedLine.length } - ); - } - }); - } + 'Ctrl-/': 'toggleComment', + 'Cmd-/': 'toggleComment' }, foldOptions: { widget: (from, to) => {