From 77eb19af405f3f5078136f5a136ccc719a311907 Mon Sep 17 00:00:00 2001 From: kostaldavid8 Date: Wed, 15 Feb 2017 23:30:56 +0100 Subject: [PATCH] Code style fixes --- browser/components/CodeEditor.js | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/browser/components/CodeEditor.js b/browser/components/CodeEditor.js index beee8961..03270de2 100644 --- a/browser/components/CodeEditor.js +++ b/browser/components/CodeEditor.js @@ -57,32 +57,43 @@ export default class CodeEditor extends React.Component { inputStyle: 'textarea', extraKeys: { Tab: function (cm) { - let cursor = cm.getCursor() - let line = cm.getLine(cursor.line) + const cursor = cm.getCursor() + const line = cm.getLine(cursor.line) if (cm.somethingSelected()) cm.indentSelection('add') else { - let tabs = cm.getOption('indentWithTabs') + const tabs = cm.getOption('indentWithTabs') if (line.trimLeft() === '- ' || line.trimLeft() === '* ') { cm.execCommand('goLineStart') - if (tabs) cm.execCommand('insertTab'); else cm.execCommand('insertSoftTab') + if (tabs) { + cm.execCommand('insertTab') + } else { + cm.execCommand('insertSoftTab') + } cm.execCommand('goLineEnd') } else { - if (tabs) cm.execCommand('insertTab'); else cm.execCommand('insertSoftTab') + if (tabs) { + cm.execCommand('insertTab') + } else { + cm.execCommand('insertSoftTab') + } } } }, 'Cmd-T': function (cm) { // Do nothing }, - Enter: function (cm) { - let cursor = cm.getCursor() - let line = cm.getLine(cursor.line) - let dash = line.trim().startsWith('- ') - if ((line.trim().startsWith('- ') || line.trim().startsWith('* '))) { + Enter: (cm) => { + const cursor = cm.getCursor() + const line = cm.getLine(cursor.line) + const dash = line.trim().startsWith('- ') + if (line.trim().startsWith('- ') || line.trim().startsWith('* ')) { cm.execCommand('newlineAndIndent') - let range = {line: cursor.line + 1, ch: cm.getLine(cursor.line + 1).length} - console.log(range) - if (dash) cm.replaceRange('- ', range); else cm.replaceRange('* ', range) + const range = {line: cursor.line + 1, ch: cm.getLine(cursor.line + 1).length} + if (dash) { + cm.replaceRange('- ', range) + } else { + cm.replaceRange('* ', range) + } } else { cm.execCommand('newlineAndIndent') }