diff options
author | pommicket <pommicket@gmail.com> | 2023-08-05 18:03:55 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2023-08-05 18:03:55 -0400 |
commit | b847c7208f15e40999118443d5a808dfe389a8fb (patch) | |
tree | 6a08682756915a86cab2e5a180b2ca85a1244aba /ted.c | |
parent | 8ef478f460a55e83efa7351021e458c87e21de17 (diff) |
separate ted-internal.h
Diffstat (limited to 'ted.c')
-rw-r--r-- | ted.c | 26 |
1 files changed, 5 insertions, 21 deletions
@@ -1,6 +1,6 @@ // various core ted functions (opening files, displaying errors, etc.) -#include "ted.h" +#include "ted-internal.h" #if _WIN32 #include <SDL_syswm.h> #endif @@ -763,20 +763,12 @@ void ted_flash_error_cursor(Ted *ted) { ted->cursor_error_time = ted->frame_time; } -void ted_go_to_position(Ted *ted, const char *path, u32 line, u32 index, bool is_lsp) { +void ted_go_to_lsp_document_position(Ted *ted, LSP *lsp, LSPDocumentPosition position) { + if (!lsp) lsp = ted_active_lsp(ted); + const char *path = lsp_document_path(lsp, position.document); if (ted_open_file(ted, path)) { TextBuffer *buffer = ted->active_buffer; - BufferPos pos = {0}; - if (is_lsp) { - LSPPosition lsp_pos = { - .line = line, - .character = index - }; - pos = buffer_pos_from_lsp(buffer, lsp_pos); - } else { - pos.line = line; - pos.index = index; - } + BufferPos pos = buffer_pos_from_lsp(buffer, position.pos); buffer_cursor_move_to_pos(buffer, pos); buffer->center_cursor_next_frame = true; } else { @@ -784,14 +776,6 @@ void ted_go_to_position(Ted *ted, const char *path, u32 line, u32 index, bool is } } -void ted_go_to_lsp_document_position(Ted *ted, LSP *lsp, LSPDocumentPosition position) { - if (!lsp) lsp = ted_active_lsp(ted); - const char *path = lsp_document_path(lsp, position.document); - u32 line = position.pos.line; - u32 character = position.pos.character; - ted_go_to_position(ted, path, line, character, true); -} - void ted_cancel_lsp_request(Ted *ted, LSPServerRequestID *request) { if (!request) return; LSP *lsp_obj = ted_get_lsp_by_id(ted, request->lsp); |