Skip to content

Commit

Permalink
fixed tokenizing lua multiline strings
Browse files Browse the repository at this point in the history
  • Loading branch information
nem0 committed Sep 4, 2023
1 parent 7611f38 commit 5016d41
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/editor/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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]));
}

Expand Down
2 changes: 1 addition & 1 deletion src/renderer/editor/render_plugins.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit 5016d41

Please sign in to comment.