Skip to content

Commit 9733a8b

Browse files
committed
UI: Edit enter now continues prior line comment
1 parent 2994204 commit 9733a8b

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

src/ui/textedit.cpp

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,25 +1188,24 @@ void TextEditInput::editEnter() {
11881188

11891189
if (prevLineStart || _cursorLine == 1) {
11901190
char spaces[LINE_BUFFER_SIZE];
1191-
int indent = getIndent(spaces, sizeof(spaces), prevLineStart);
1192-
if (indent) {
1193-
// check whether the previous line was a comment
1194-
if (prevLineStart) {
1195-
char *buf = lineText(prevLineStart);
1196-
int pos = 0;
1197-
while (buf && (buf[pos] == ' ' || buf[pos] == '\t')) {
1198-
pos++;
1199-
}
1200-
if ((buf[pos] == '#' || buf[pos] == '\'') && indent + 2 < LINE_BUFFER_SIZE) {
1201-
spaces[indent] = buf[pos];
1202-
spaces[++indent] = ' ';
1203-
spaces[++indent] = '\0';
1204-
} else if (strncasecmp(buf + pos, "rem", 3) == 0) {
1205-
indent = strlcat(spaces, "rem ", LINE_BUFFER_SIZE);
1206-
}
1207-
free(buf);
1208-
}
1191+
int indent = getIndent(spaces, LINE_BUFFER_SIZE, prevLineStart);
12091192

1193+
// check whether the previous line was a comment
1194+
char *buf = lineText(prevLineStart);
1195+
int pos = 0;
1196+
while (buf && (buf[pos] == ' ' || buf[pos] == '\t')) {
1197+
pos++;
1198+
}
1199+
if ((buf[pos] == '#' || buf[pos] == '\'') && indent + 2 < LINE_BUFFER_SIZE) {
1200+
spaces[indent] = buf[pos];
1201+
spaces[++indent] = ' ';
1202+
spaces[++indent] = '\0';
1203+
} else if (strncasecmp(buf + pos, "rem", 3) == 0) {
1204+
indent = strlcat(spaces, "rem ", LINE_BUFFER_SIZE);
1205+
}
1206+
free(buf);
1207+
1208+
if (indent) {
12101209
_buf.insertChars(_state.cursor, spaces, indent);
12111210
stb_text_makeundo_insert(&_state, _state.cursor, indent);
12121211
_state.cursor += indent;

0 commit comments

Comments
 (0)