From d79ea4e75a6e0f7c93d4108d829b541f2e9648a3 Mon Sep 17 00:00:00 2001 From: Syed Daanish Date: Thu, 5 Feb 2026 14:23:52 +0000 Subject: [PATCH] Fix parser bug on newlines --- include/lsp/lsp.h | 4 +--- src/editor/click.cc | 5 +---- src/editor/edit.cc | 2 -- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/include/lsp/lsp.h b/include/lsp/lsp.h index 15239dd..3e66ed2 100644 --- a/include/lsp/lsp.h +++ b/include/lsp/lsp.h @@ -116,9 +116,7 @@ struct LSPInstance { } } allow_formatting = caps.value("documentFormattingProvider", false); - if (lsp_id != "lua-language-server" /* Lua ls gives terrible ontype - formatting so disable */ - && caps.contains("documentOnTypeFormattingProvider")) { + if (caps.contains("documentOnTypeFormattingProvider")) { auto &fmt = caps["documentOnTypeFormattingProvider"]; if (fmt.is_object()) { if (fmt.contains("firstTriggerCharacter")) { diff --git a/src/editor/click.cc b/src/editor/click.cc index aba4047..06f718c 100644 --- a/src/editor/click.cc +++ b/src/editor/click.cc @@ -1,13 +1,10 @@ #include "editor/editor.h" -#include "main.h" Coord Editor::click_coord(uint32_t x, uint32_t y) { - if (mode == INSERT) - x++; uint32_t numlen = EXTRA_META + static_cast(std::log10(this->root->line_count + 1)); uint32_t render_width = this->size.col - numlen; - x = MAX(x, numlen) - numlen + 1; + x = MAX(x, numlen) - numlen - 1; uint32_t target_visual_row = y; uint32_t visual_row = 0; uint32_t line_index = this->scroll.row; diff --git a/src/editor/edit.cc b/src/editor/edit.cc index cda9876..f079f8f 100644 --- a/src/editor/edit.cc +++ b/src/editor/edit.cc @@ -232,8 +232,6 @@ void Editor::edit_replace(Coord start, Coord end, const char *text, for (uint32_t i = 0; i < len; i++) if (text[i] == '\n') rows++; - if (rows > 0) - rows--; if (this->parser) this->parser->edit(start.row, end.row - start.row, rows); auto lsp = this->lsp.load();