Merge branch 'dev' into debugging-server
This commit is contained in:
commit
5eceed3737
@ -558,7 +558,7 @@ local internal_locked = false
|
||||
-- Example `base:scripts/tests.lua`
|
||||
--
|
||||
-- nocache - ignore cached script, load anyway
|
||||
function __load_script(path, nocache)
|
||||
local function __load_script(path, nocache, env)
|
||||
local packname, filename = parse_path(path)
|
||||
|
||||
if internal_locked and (packname == "res" or packname == "core")
|
||||
@ -578,6 +578,9 @@ function __load_script(path, nocache)
|
||||
if script == nil then
|
||||
error(err)
|
||||
end
|
||||
if env then
|
||||
script = setfenv(script, env)
|
||||
end
|
||||
local result = script()
|
||||
if not nocache then
|
||||
__cached_scripts[path] = script
|
||||
@ -593,10 +596,11 @@ end
|
||||
function require(path)
|
||||
if not string.find(path, ':') then
|
||||
local prefix, _ = parse_path(_debug_getinfo(2).source)
|
||||
return require(prefix..':'..path)
|
||||
return require(prefix .. ':' .. path)
|
||||
end
|
||||
local prefix, file = parse_path(path)
|
||||
return __load_script(prefix..":modules/"..file..".lua")
|
||||
local env = __vc__pack_envs[prefix]
|
||||
return __load_script(prefix .. ":modules/" .. file .. ".lua", nil, env)
|
||||
end
|
||||
|
||||
function __scripts_cleanup()
|
||||
|
||||
@ -1211,13 +1211,12 @@ void TextBox::setCaret(size_t position) {
|
||||
}
|
||||
int lcaret = caret - rawTextCache.getTextLineOffset(line);
|
||||
int realoffset =
|
||||
rawTextCache.metrics.calcWidth(labelText, lcaret) - static_cast<int>(textOffset) + 2;
|
||||
rawTextCache.metrics.calcWidth(labelText, 0, lcaret) - static_cast<int>(textOffset) + 2;
|
||||
|
||||
if (realoffset - width > 0) {
|
||||
setTextOffset(textOffset + realoffset - width);
|
||||
} else if (realoffset < 0) {
|
||||
setTextOffset(std::max(textOffset + realoffset, static_cast<size_t>(0))
|
||||
);
|
||||
setTextOffset(std::max(textOffset + realoffset, static_cast<size_t>(0)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -105,6 +105,9 @@ void lua::init_state(State* L, StateType stateType) {
|
||||
pushnil(L);
|
||||
setglobal(L, "io");
|
||||
|
||||
createtable(L, 0, 0);
|
||||
setglobal(L, "__vc__pack_envs");
|
||||
|
||||
const char* removed_os[] {
|
||||
"execute", "exit", "remove", "rename", "setlocale", "tmpname", nullptr};
|
||||
remove_lib_funcs(L, "os", removed_os);
|
||||
|
||||
@ -181,7 +181,17 @@ std::unique_ptr<Process> scripting::start_coroutine(const io::path& script) {
|
||||
lua::setfield(L, "PACK_ENV");
|
||||
lua::pushstring(L, pack.id);
|
||||
lua::setfield(L, "PACK_ID");
|
||||
|
||||
lua::dump_stack(L);
|
||||
if(!lua::getglobal(L, "__vc__pack_envs")) {
|
||||
lua::createtable(L, 0, 0);
|
||||
lua::setglobal(L, "__vc__pack_envs");
|
||||
lua::pushvalue(L, -1);
|
||||
}
|
||||
lua::pushenv(L, id);
|
||||
lua::setfield(L, pack.id);
|
||||
lua::pop(L);
|
||||
|
||||
return std::shared_ptr<int>(new int(id), [=](int* id) { //-V508
|
||||
lua::remove_environment(L, *id);
|
||||
delete id;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user