@@ -973,7 +973,8 @@ void TextEditInput::editEnter() {
973973 char spaces[LINE_BUFFER_SIZE];
974974 int start = lineStart (_state.cursor );
975975 int prevLineStart = lineStart (start - 1 );
976- if (prevLineStart >= 0 ) {
976+
977+ if (prevLineStart || _cursorLine == 1 ) {
977978 int indent = getIndent (spaces, sizeof (spaces), prevLineStart);
978979 if (indent) {
979980 _buf.insertChars (_state.cursor , spaces, indent);
@@ -996,7 +997,7 @@ void TextEditInput::editTab() {
996997 prevLineStart = lineStart (prevLineStart - 1 );
997998 }
998999 // note - spaces not used in this context
999- indent = prevLineStart == 0 ? 0 : getIndent (spaces, sizeof (spaces), prevLineStart);
1000+ indent = ( prevLineStart || _cursorLine == 2 ) ? getIndent (spaces, sizeof (spaces), prevLineStart) : 0 ;
10001001
10011002 // get the current lines indent
10021003 char *buf = lineText (start);
@@ -1176,7 +1177,7 @@ int TextEditInput::getIndent(char *spaces, int len, int pos) {
11761177 // count the indent level and find the start of text
11771178 char *buf = lineText (pos);
11781179 int i = 0 ;
1179- while (buf && buf[i] == ' ' && i < len) {
1180+ while (buf && ( buf[i] == ' ' || buf[i] == ' \t ' ) && i < len) {
11801181 spaces[i] = buf[i];
11811182 i++;
11821183 }
@@ -1205,7 +1206,7 @@ int TextEditInput::getIndent(char *spaces, int len, int pos) {
12051206 j++;
12061207 }
12071208 // right trim trailing spaces
1208- while (buf[j - 1 ] == ' ' && j > i) {
1209+ while (( buf[j - 1 ] == ' ' || buf[j - 1 ] == ' \t ' ) && j > i) {
12091210 j--;
12101211 }
12111212 if (strncasecmp (buf + j - 4 , " then" , 4 ) != 0 ) {
0 commit comments