From 3d780753c4a129d6b620f11564c2e0201ac2b6a8 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sun, 2 Oct 2016 17:14:01 -0400 Subject: [PATCH] Handle tab press --- js/type.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/js/type.js b/js/type.js index d6424e1..e15f6e2 100644 --- a/js/type.js +++ b/js/type.js @@ -165,6 +165,9 @@ function handleKeyDown(event) { } else if (event.keyCode == 13) { // enter event.preventDefault(); handleEnter(event); + } else if (event.keyCode == 9) { // tab + event.preventDefault(); + handleTab(event); } } } @@ -225,6 +228,14 @@ function handleEnter(event) { } } +function handleTab(event) { + let pos = editor.getCursor(); + let line = editor.doc.getLine(pos.line); + if (line.charCodeAt(pos.ch) == 9) { + setCursor({ line: pos.line, ch: pos.ch + 1 }); + } +} + function moveToEndOfPreviousLine() { let pos = editor.getCursor(); if (pos.line > 0) {