From 5016d416c4c4db112a7fc63b000e3ebed885e713 Mon Sep 17 00:00:00 2001 From: Mikulas Florek Date: Tue, 5 Sep 2023 00:12:12 +0200 Subject: [PATCH] fixed tokenizing lua multiline strings --- src/editor/utils.cpp | 19 ++++++++++++------- src/renderer/editor/render_plugins.cpp | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/editor/utils.cpp b/src/editor/utils.cpp index 360582d6a9..2a2bd43e5d 100644 --- a/src/editor/utils.cpp +++ b/src/editor/utils.cpp @@ -77,7 +77,15 @@ static bool tokenize(const char* str, u32& token_len, u8& token_type, u8 prev_to const char* c = str; if (!*c) { - token_type = prev_token_type == (u8)TokenType::COMMENT_MULTI ? (u8)TokenType::COMMENT_MULTI : (u8)TokenType::EMPTY; + switch (prev_token_type) { + case (u8)TokenType::COMMENT_MULTI: + case (u8)TokenType::STRING_MULTI: + token_type = prev_token_type; + break; + default: + token_type = (u8)TokenType::EMPTY; + break; + } token_len = 0; return false; } @@ -1023,13 +1031,10 @@ struct CodeEditorImpl final : CodeEditor { ImRect bb = { min, min + content_size }; ImGui::ItemSize(bb); ImGui::ItemAdd(bb, id); - if (m_focus_editor) { - ImGuiEx::SetActiveID(id); - m_focus_editor = false; - } const bool hovered = ImGui::ItemHoverable(bb, id, 0); const bool clicked = hovered && ImGui::IsItemClicked(); - if (clicked && !ImGui::IsItemActive()) { + if (m_focus_editor || clicked && !ImGui::IsItemActive()) { + m_focus_editor = false; ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGui::SetActiveID(id, window); ImGui::SetFocusID(id, window); @@ -1159,7 +1164,7 @@ struct CodeEditorImpl final : CodeEditor { m_search_visible = true; m_focus_search = true; m_search_from = m_cursors[0]; - if (m_cursors[0].hasSelection()) copy(Span(m_search_text), m_cursors[0]); + if (m_cursors[0].hasSelection() && m_cursors[0].line == m_cursors[0].sel.line) copy(Span(m_search_text), m_cursors[0]); else copy(Span(m_search_text), getWord(m_cursors[0])); } diff --git a/src/renderer/editor/render_plugins.cpp b/src/renderer/editor/render_plugins.cpp index 63ec5daa4b..aca26dbdf7 100644 --- a/src/renderer/editor/render_plugins.cpp +++ b/src/renderer/editor/render_plugins.cpp @@ -2938,7 +2938,7 @@ struct ModelPlugin final : AssetBrowser::IPlugin, AssetCompiler::IPlugin { { if (!m_tile.world) createTileWorld(); RenderModule* render_module = (RenderModule*)m_tile.world->getModule(MODEL_INSTANCE_TYPE); - if (!render_module || model->getMeshCount() == 0) { + if (!render_module || !model->isReady() || model->getMeshCount() == 0) { return; }