diff options
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 20 |
1 files changed, 12 insertions, 8 deletions
@@ -39,14 +39,6 @@ struct BufferEdit { double time; // time at start of edit (i.e. the time just before the edit), in seconds since epoch }; -typedef struct { - MessageType severity; - BufferPos pos; - char *message; - // may be NULL - char *url; -} Diagnostic; - struct TextBuffer { /// NULL if this buffer is untitled or doesn't correspond to a file (e.g. line buffers) char *path; @@ -1004,6 +996,7 @@ static void buffer_line_free(Line *line) { static void diagnostic_free(Diagnostic *diagnostic) { free(diagnostic->message); free(diagnostic->url); + free(diagnostic->raw); memset(diagnostic, 0, sizeof *diagnostic); } @@ -2667,6 +2660,9 @@ void buffer_delete_chars_at_pos(TextBuffer *buffer, BufferPos pos, i64 nchars_) // just in case buffer_pos_validate(buffer, &buffer->cursor_pos); buffer_pos_validate(buffer, &buffer->selection_pos); + if (buffer_pos_eq(buffer->cursor_pos, buffer->selection_pos)) { + buffer->selection = false; + } // we need to do this *after* making the change to the buffer // because of how non-incremental syncing works. @@ -3536,6 +3532,8 @@ bool buffer_handle_click(Ted *ted, TextBuffer *buffer, vec2 click, u8 times) { else autocomplete_close(ted); // close autocomplete menu if user clicks outside of it } + if (code_action_is_open(ted)) + return false; if (buffer_pixels_to_pos(buffer, click, &buffer_pos)) { // user clicked on buffer if (!menu_is_any_open(ted) || buffer->is_line_buffer) { @@ -4245,7 +4243,9 @@ void buffer_publish_diagnostics(TextBuffer *buffer, const LSPRequest *request, L arr_foreach_ptr(diagnostics, const LSPDiagnostic, diagnostic) { Diagnostic *d = arr_addp(buffer->diagnostics); d->pos = buffer_pos_from_lsp(buffer, diagnostic->range.start); + d->end = buffer_pos_from_lsp(buffer, diagnostic->range.end); d->severity = diagnostic_severity(diagnostic); + d->raw = str_dup(lsp_request_string(request, diagnostic->raw)); char message[280]; const char *code = lsp_request_string(request, diagnostic->code); if (*code) { @@ -4287,3 +4287,7 @@ void buffer_set_inotify_modified(TextBuffer *buffer) { buffer->inotify_modified = true; } #endif + +const Diagnostic *buffer_diagnostics(TextBuffer *buffer) { + return buffer->diagnostics; +} |