summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAlbert Cervin <albert@acervin.com>2025-11-21 21:46:18 +0100
committerAlbert Cervin <albert@acervin.com>2025-11-21 21:46:18 +0100
commit3940a20f62baf567cf31e1206adba050b477c9fa (patch)
tree4437c6b5ad20b264d3576717923d7f1f5a9c12f5 /src/main
parentfd5683cdc61efa37a1be7b94901f75c5409d2297 (diff)
downloaddged-3940a20f62baf567cf31e1206adba050b477c9fa.tar.gz
dged-3940a20f62baf567cf31e1206adba050b477c9fa.tar.xz
dged-3940a20f62baf567cf31e1206adba050b477c9fa.zip
Fix the yellow on yellow for warnings
Diagnostic highlight now sets the fg to white and the background to the appropriate color for the diagnostic severity. Before, we could end up with a yellow color for warning as background and a yellow as foreground for a function, which caused unreadable text. Also fix some more cases where re-render is needed.
Diffstat (limited to 'src/main')
-rw-r--r--src/main/lsp.c7
-rw-r--r--src/main/main.c3
2 files changed, 8 insertions, 2 deletions
diff --git a/src/main/lsp.c b/src/main/lsp.c
index ab9ba39..de7f553 100644
--- a/src/main/lsp.c
+++ b/src/main/lsp.c
@@ -50,6 +50,7 @@ struct lsp_server {
enum position_encoding_kind position_encoding;
struct lsp_diagnostics *diagnostics;
+ layer_id diagnostics_layer_id;
struct completion_ctx *completion_ctx;
};
@@ -192,6 +193,8 @@ request_response_received(struct lsp_server *server, uint64_t id,
static void buffer_updated(struct buffer *buffer, void *userdata) {
struct lsp_server *server = (struct lsp_server *)userdata;
+ buffer_clear_text_property_layer(buffer, server->diagnostics_layer_id);
+
diagnostic_vec *diagnostics =
diagnostics_for_buffer(server->diagnostics, buffer);
if (diagnostics == NULL) {
@@ -213,7 +216,8 @@ static void buffer_updated(struct buffer *buffer, void *userdata) {
struct region reg = region_new(
diag->region.begin, buffer_previous_char(buffer, diag->region.end));
- buffer_add_text_property(buffer, reg.begin, reg.end, prop);
+ buffer_add_text_property_to_layer(buffer, reg.begin, reg.end, prop,
+ server->diagnostics_layer_id);
if (window_buffer(windows_get_active()) == buffer) {
struct buffer_view *bv = window_buffer_view(windows_get_active());
@@ -589,6 +593,7 @@ static void create_lsp_client(struct buffer *buffer, void *userdata) {
}
new->value.diagnostics = diagnostics_create();
+ new->value.diagnostics_layer_id = buffer_add_text_property_layer(buffer);
// support for this is determined later
new->value.completion_ctx = NULL;
diff --git a/src/main/main.c b/src/main/main.c
index 57c2454..a10a461 100644
--- a/src/main/main.c
+++ b/src/main/main.c
@@ -431,7 +431,8 @@ int main(int argc, char *argv[]) {
* reason. This is also the reason that there is no timed scope around
* this, it simply makes no sense.
*/
- reactor_update(reactor, needs_render ? (time_to_render_ns / 1e6) : -1);
+ reactor_update(reactor,
+ needs_render ? ((time_to_render_ns + 1e6 - 1) / 1e6) : -1);
}
struct timer *update_keyboard = timer_start("update-keyboard");