Skip to content

Commit

Permalink
eval evaluates current line if nothing selected (#211)
Browse files Browse the repository at this point in the history
add Ctl+Enter as eval key binding
  • Loading branch information
schollz authored Jun 12, 2021
1 parent 9062028 commit 97d003e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions web/src/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,11 @@ class Editor extends Component {
}

handleEval() {
const code = this.editor.getSelectedText().replace(/--.*\n/g,';').replace(/\n/g,';')
this.props.selectionEval(code);
var code = this.editor.getSelectedText();
if (code==="") {
code = this.editor.session.getLine(this.editor.getSelectionRange().start.row);
}
this.props.selectionEval(code.replace(/--.*\n/g,';').replace(/\n/g,';'));
}

render() {
Expand Down
1 change: 1 addition & 0 deletions web/src/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ keyService.bindings = [
new KeyBinding(new KeyStroke(Modifier.CMD, 'b'), 'toggle sidebar'),
new KeyBinding(new KeyStroke(Modifier.CMD, ';'), 'show config'),
new KeyBinding(new KeyStroke(Modifier.CMD, '8'), 'eval'),
new KeyBinding(new KeyStroke(Modifier.CMD, 'enter'), 'eval'),
];

class TextMode extends EditorMode {
Expand Down

0 comments on commit 97d003e

Please sign in to comment.