summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-07-07 11:17:14 -0400
committerpommicket <pommicket@gmail.com>2022-07-07 11:17:14 -0400
commit1e5e20d2749690caaf5a084f90064346ec88d381 (patch)
treef346c153a9646a4819d2f7e497c39c5590bad583
parent7f68731fb7e5caa41acb10804e7786a6041d5ced (diff)
[1.0r3] fix tex highlighting, move to cursor on backspace/delete
-rw-r--r--buffer.c10
-rw-r--r--syntax.c5
2 files changed, 11 insertions, 4 deletions
diff --git a/buffer.c b/buffer.c
index 8e9dfe4..4fa05ef 100644
--- a/buffer.c
+++ b/buffer.c
@@ -1789,6 +1789,7 @@ void buffer_delete_chars_at_cursor(TextBuffer *buffer, i64 nchars) {
buffer_delete_selection(buffer);
else
buffer_delete_chars_at_pos(buffer, buffer->cursor_pos, nchars);
+ buffer_scroll_to_cursor(buffer);
}
i64 buffer_backspace_at_pos(TextBuffer *buffer, BufferPos *pos, i64 ntimes) {
@@ -1799,10 +1800,13 @@ i64 buffer_backspace_at_pos(TextBuffer *buffer, BufferPos *pos, i64 ntimes) {
// returns number of characters backspaced
i64 buffer_backspace_at_cursor(TextBuffer *buffer, i64 ntimes) {
+ i64 ret = 0;
if (buffer->selection)
- return buffer_delete_selection(buffer);
+ ret = buffer_delete_selection(buffer);
else
- return buffer_backspace_at_pos(buffer, &buffer->cursor_pos, ntimes);
+ ret = buffer_backspace_at_pos(buffer, &buffer->cursor_pos, ntimes);
+ buffer_scroll_to_cursor(buffer);
+ return ret;
}
void buffer_delete_words_at_pos(TextBuffer *buffer, BufferPos pos, i64 nwords) {
@@ -1816,6 +1820,7 @@ void buffer_delete_words_at_cursor(TextBuffer *buffer, i64 nwords) {
buffer_delete_selection(buffer);
else
buffer_delete_words_at_pos(buffer, buffer->cursor_pos, nwords);
+ buffer_scroll_to_cursor(buffer);
}
void buffer_backspace_words_at_pos(TextBuffer *buffer, BufferPos *pos, i64 nwords) {
@@ -1829,6 +1834,7 @@ void buffer_backspace_words_at_cursor(TextBuffer *buffer, i64 nwords) {
buffer_delete_selection(buffer);
else
buffer_backspace_words_at_pos(buffer, &buffer->cursor_pos, nwords);
+ buffer_scroll_to_cursor(buffer);
}
// puts the inverse edit into `inverse`
diff --git a/syntax.c b/syntax.c
index 9903cf4..b3504bc 100644
--- a/syntax.c
+++ b/syntax.c
@@ -133,6 +133,7 @@ static inline bool syntax_number_continues(char32_t const *line, u32 line_len, u
}
static bool is_keyword(Language lang, char32_t c) {
+ if (c == '_' && lang == LANG_TEX) return false;
if (is32_ident(c)) return true;
switch (lang) {
case LANG_RUST:
@@ -581,8 +582,8 @@ static void syntax_highlight_python(SyntaxState *state, char32_t const *line, u3
}
static bool is_tex_ident(char32_t c) {
- // digits cannot appear in tex identifiers
- return is32_ident(c) && !is32_digit(c);
+ // digits and underscores cannot appear in tex identifiers
+ return is32_ident(c) && !is32_digit(c) && c != '_';
}
static void syntax_highlight_tex(SyntaxState *state, char32_t const *line, u32 line_len, SyntaxCharType *char_types) {