summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/dged/display.c11
-rw-r--r--src/dged/reactor-kqueue.c2
-rw-r--r--src/dged/syntax.c16
-rw-r--r--src/dged/window.c6
4 files changed, 31 insertions, 4 deletions
diff --git a/src/dged/display.c b/src/dged/display.c
index e39391b..e992cc9 100644
--- a/src/dged/display.c
+++ b/src/dged/display.c
@@ -7,6 +7,7 @@
#include <assert.h>
#include <ctype.h>
+#include <fcntl.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
@@ -91,7 +92,15 @@ struct command_list {
struct winsize getsize(void) {
struct winsize ws;
- ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
+ if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws) == -1 || ws.ws_row == 0 ||
+ ws.ws_col == 0) {
+ int fd = open("/dev/tty", O_RDONLY);
+ if (fd != -1) {
+ ioctl(fd, TIOCGWINSZ, &ws);
+ close(fd);
+ }
+ }
+
return ws;
}
diff --git a/src/dged/reactor-kqueue.c b/src/dged/reactor-kqueue.c
index f30cb9a..d370653 100644
--- a/src/dged/reactor-kqueue.c
+++ b/src/dged/reactor-kqueue.c
@@ -81,6 +81,7 @@ uint32_t reactor_register_interest(struct reactor *reactor, int fd,
uint32_t reactor_watch_file(struct reactor *reactor, const char *path,
uint32_t mask) {
+ (void)mask;
uint32_t fflags = NOTE_WRITE | NOTE_DELETE | NOTE_RENAME | NOTE_REVOKE;
int fd = open(path, O_RDONLY);
if (fd < 0) {
@@ -99,6 +100,7 @@ uint32_t reactor_watch_file(struct reactor *reactor, const char *path,
}
void reactor_unwatch_file(struct reactor *reactor, uint32_t id) {
+ (void)reactor;
// all kevents for this fd are removed automatically when closed
close(id);
}
diff --git a/src/dged/syntax.c b/src/dged/syntax.c
index 67ab3a2..5d9aeaa 100644
--- a/src/dged/syntax.c
+++ b/src/dged/syntax.c
@@ -567,7 +567,16 @@ static void create_parser(struct buffer *buffer, void *userdata) {
struct highlight *hl =
(struct highlight *)calloc(1, sizeof(struct highlight));
hl->parser = ts_parser_new();
- ts_parser_set_language(hl->parser, langsym());
+ struct TSLanguage *lang = langsym();
+ if (!ts_parser_set_language(hl->parser, lang)) {
+ message("failed to assign language to parser, abi version %d, lib version: "
+ "%d, min compatible lib version: %d",
+ ts_language_version(lang), TREE_SITTER_LANGUAGE_VERSION,
+ TREE_SITTER_MIN_COMPATIBLE_LANGUAGE_VERSION);
+ ts_parser_delete(hl->parser);
+ free((void *)lang_root);
+ return;
+ }
TSInput i = (TSInput){
.payload = buffer->text,
@@ -575,6 +584,11 @@ static void create_parser(struct buffer *buffer, void *userdata) {
.encoding = TSInputEncodingUTF8,
};
hl->tree = ts_parser_parse(hl->parser, NULL, i);
+ if (hl->tree == NULL) {
+ ts_parser_delete(hl->parser);
+ free((void *)lang_root);
+ return;
+ }
hl->query = setup_queries(lang_root, hl->tree);
if (hl->query == NULL) {
diff --git a/src/dged/window.c b/src/dged/window.c
index cad3c7e..7ad4794 100644
--- a/src/dged/window.c
+++ b/src/dged/window.c
@@ -85,11 +85,13 @@ void windows_init(uint32_t height, uint32_t width,
struct buffers *buffers) {
BINTREE_INIT(&g_windows.windows);
+ uint32_t height_ = height > 0 ? height - 1 : 0;
+
g_minibuffer_window = (struct window){
.buffer_view = buffer_view_create(minibuffer, false, false),
.has_prev_buffer_view = false,
.x = 0,
- .y = height - 1,
+ .y = height_,
.height = 1,
.width = width,
};
@@ -97,7 +99,7 @@ void windows_init(uint32_t height, uint32_t width,
struct window root_window = (struct window){
.buffer_view = buffer_view_create(initial_buffer, true, true),
.has_prev_buffer_view = false,
- .height = height - 1,
+ .height = height_,
.width = width,
.x = 0,
.y = 0,