From 104b7e71e278843f475d2a59cf652e285a5babef Mon Sep 17 00:00:00 2001 From: Li Jin Date: Thu, 25 Apr 2024 10:58:24 +0800 Subject: [PATCH] fix Yuescript traceback rewrite issue, fix character '\t' display. --- Source/3rdParty/yuescript/stacktraceplus.h | 6 +++--- Source/Node/Label.cpp | 11 ++++++++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/Source/3rdParty/yuescript/stacktraceplus.h b/Source/3rdParty/yuescript/stacktraceplus.h index 3167ba8b0..594afb5b2 100644 --- a/Source/3rdParty/yuescript/stacktraceplus.h +++ b/Source/3rdParty/yuescript/stacktraceplus.h @@ -1,6 +1,6 @@ R"lua_codes( --[[ -Copyright (c) 2010 Ignacio Burgueño, modified by Li Jin +Copyright (c) 2010 Ignacio Burgueño, modified by Li Jin, 2024 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal @@ -335,7 +335,7 @@ local function getYueLineNumber(fname, line) end if file_exist then local codes = yue.read_file(file_path) - local yueFile = codes:match("^%s*--%s*%[.*%]:%s*([^\n]*)") + local yueFile = codes:match("^%s*%-%-%s*%[[^%]]*%]:%s*([^\n]*)") if yueFile then fname = yueFile:gsub("^%s*(.-)%s*$", "%1") source = codes @@ -346,7 +346,7 @@ local function getYueLineNumber(fname, line) local current, target = 1, tonumber(line) local findLine = line for lineCode in source:gmatch("([^\r\n]*)\r?\n?") do - local num = lineCode:match("--%s*(%d+)%s*$") + local num = lineCode:match("%-%-%s*(%d+)%s*$") if num then findLine = num end diff --git a/Source/Node/Label.cpp b/Source/Node/Label.cpp index b942f1fb3..2014619f0 100644 --- a/Source/Node/Label.cpp +++ b/Source/Node/Label.cpp @@ -585,7 +585,16 @@ void Label::updateCharacters(const std::vector& chars) { } void Label::updateLabel() { - _text = utf8_get_characters(_textUTF8.c_str()); + auto text = utf8_get_characters(_textUTF8.c_str()); + _text.clear(); + for (auto elem : text) { + if (elem == '\t') { + _text.push_back(' '); + _text.push_back(' '); + } else { + _text.push_back(elem); + } + } _text.push_back('\0'); if (_flags.isOn(Label::TextBatched)) {