Fix an error in areas_to_command; Tweaks.

This commit is contained in:
Xinhao Yuan 2021-02-25 23:50:35 -05:00
parent 7433ddd1ea
commit 8a304d7c5a
3 changed files with 30 additions and 28 deletions

View File

@ -462,7 +462,7 @@ function module.create(data)
local function run_cmd(cmd, screen, tag) local function run_cmd(cmd, screen, tag)
local gap = tag.gap local gap = tag.gap
local areas = machi_engine.areas_from_command( local areas, closed = machi_engine.areas_from_command(
cmd, cmd,
{ {
x = screen.workarea.x + gap, x = screen.workarea.x + gap,
@ -471,7 +471,7 @@ function module.create(data)
height = screen.workarea.height - gap * 2 height = screen.workarea.height - gap * 2
}, },
gap * 2 + data.minimum_size) gap * 2 + data.minimum_size)
if not areas then if not areas or #closed > 0 then
return nil return nil
end end
for _, a in ipairs(areas) do for _, a in ipairs(areas) do

View File

@ -859,32 +859,27 @@ local function areas_to_command(areas, to_embed)
end end
end end
local acc_dashes = 0 local acc_dashes = 0
for _, c in ipairs(a.split.children) do if a.expansion > 1 then
local cr = get_command(c.id) for _, c in ipairs(a.split.children) do
if cr == "-" then local cr = get_command(c.id)
acc_dashes = acc_dashes + 1 if cr == "-" then
else acc_dashes = acc_dashes + 1
if acc_dashes == 0 then
elseif acc_dashes == 1 then
r = r.."-"
else else
r = r.."c"..tonumber(acc_dashes) if acc_dashes == 0 then
elseif acc_dashes == 1 then
r = r.."-"
else
r = r.."c"..tonumber(acc_dashes)
end
acc_dashes = 0
r = r..cr
end end
acc_dashes = 0 end
r = r..cr if acc_dashes > 0 then
r = r.."c"
end end
end end
if acc_dashes > 0 then
r = r.."c"
end
elseif a.disabled then
r = "/"
elseif a.layout then
r = "x"..a.layout
else
r = "-"
end
if a.split then
if a.parent_id then if a.parent_id then
if a.expansion ~= areas[a.parent_id].expansion - 1 then if a.expansion ~= areas[a.parent_id].expansion - 1 then
r = "t"..tostring(a.expansion)..r r = "t"..tostring(a.expansion)..r
@ -894,7 +889,14 @@ local function areas_to_command(areas, to_embed)
r = "t"..tostring(a.expansion)..r r = "t"..tostring(a.expansion)..r
end end
end end
elseif a.disabled then
r = "/"
elseif a.layout then
r = "x"..a.layout
else
r = "-"
end end
return r return r
end end
@ -924,9 +926,9 @@ if not in_module then
check_transcoded_command("1_10,2,1h1s131v.", "h1_10,2,1-v1,3,1.") check_transcoded_command("1_10,2,1h1s131v.", "h1_10,2,1-v1,3,1.")
check_transcoded_command("332111w.", "w3,3,2,1,1,1.") check_transcoded_command("332111w.", "w3,3,2,1,1,1.")
check_transcoded_command("1310111d.", ";d1,3,1,,1,1,1.") check_transcoded_command("1310111d.", ";d1,3,1,,1,1,1.")
check_transcoded_command("dw66.", "dw6,6.") check_transcoded_command("dw66.", "dw6,6")
check_transcoded_command(";dw66.", ";dw6,6.") check_transcoded_command(";dw66.", ";dw6,6")
check_transcoded_command("101dw66.", ";dw6,6.") check_transcoded_command("101dw66.", ";dw6,6")
check_transcoded_command("3tdw66.", "t3;dw6,6.") check_transcoded_command("3tdw66.", "t3;dw6,6.")
print("Passed.") print("Passed.")
end end

View File

@ -203,7 +203,7 @@ function module.create(args_or_name, editor, default_cmd)
local instance = get_instance_(tag) local instance = get_instance_(tag)
local areas, draft_mode = get_areas(screen, tag) local areas, draft_mode = get_areas(screen, tag)
if #areas == 0 then return end if areas == nil then return end
local nested_clients = {} local nested_clients = {}
for _, c in ipairs(cls) do for _, c in ipairs(cls) do