summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2022-07-21 23:46:56 -0400
committerpommicket <pommicket@gmail.com>2022-07-21 23:46:56 -0400
commit47a65f608f485af32d2df12be489146ad67839e1 (patch)
tree998051aba1da5da4a75e51bfee9a9a5d5b00b517 /buffer.c
parent08da42c48bf40f24faa91c00b777ae15ac8f706b (diff)
minor fixes, syntax highlighting for java & js
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/buffer.c b/buffer.c
index 4fa05ef..50a75fe 100644
--- a/buffer.c
+++ b/buffer.c
@@ -2183,6 +2183,13 @@ bool buffer_save(TextBuffer *buffer) {
bool buffer_save_as(TextBuffer *buffer, char const *new_filename) {
char *prev_filename = buffer->filename;
if ((buffer->filename = buffer_strdup(buffer, new_filename))) {
+ buffer->view_only = false;
+
+ // ensure whole file is syntax highlighted when saving with a different
+ // file extension
+ buffer->frame_earliest_line_modified = 0;
+ buffer->frame_latest_line_modified = buffer->nlines - 1;
+
if (buffer_save(buffer)) {
free(prev_filename);
return true;
@@ -2428,6 +2435,8 @@ void buffer_render(TextBuffer *buffer, Rect r) {
if (buffer->frame_latest_line_modified >= buffer->frame_earliest_line_modified
&& syntax_highlighting) {
// update syntax cache
+ if (buffer->frame_latest_line_modified >= buffer->nlines)
+ buffer->frame_latest_line_modified = buffer->nlines - 1;
Line *earliest = &buffer->lines[buffer->frame_earliest_line_modified];
Line *latest = &buffer->lines[buffer->frame_latest_line_modified];
Line *buffer_last_line = &buffer->lines[buffer->nlines - 1];