mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-21 15:33:11 +01:00
fix/ Script execution is prevented by line comments (#3462)
* refactor: simplify mode settings and update comment toggle functionality --------- Co-authored-by: Anoop M D <anoop.md1421@gmail.com>
This commit is contained in:
parent
d92dd46d4e
commit
84095a4183
@ -190,32 +190,8 @@ export default class CodeEditor extends React.Component {
|
|||||||
'Cmd-Y': 'foldAll',
|
'Cmd-Y': 'foldAll',
|
||||||
'Ctrl-I': 'unfoldAll',
|
'Ctrl-I': 'unfoldAll',
|
||||||
'Cmd-I': 'unfoldAll',
|
'Cmd-I': 'unfoldAll',
|
||||||
'Cmd-/': (cm) => {
|
'Ctrl-/': 'toggleComment',
|
||||||
// comment/uncomment every selected line(s)
|
'Cmd-/': 'toggleComment'
|
||||||
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 }
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
foldOptions: {
|
foldOptions: {
|
||||||
widget: (from, to) => {
|
widget: (from, to) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user