fix: fallback for missing entries in columns file

This commit is contained in:
aclist 2026-05-25 15:11:21 +09:00
parent 6d7ed80996
commit ba7a2b7ab4
2 changed files with 12 additions and 5 deletions

View File

@ -18,15 +18,20 @@ def has_new_config(config: Path) -> bool:
def migrate_cols_file(res: Path) -> None:
# NOTE: dzg.columns.json is API 7 spec
# NOTE: filename "dzg.columns.json" is API 7 spec
old_res = Path.home() / LEGACY_COLS_PATH
if old_res.is_file():
j = read_json(old_res)
cols = j["cols"]
# NOTE: implies prior conversion
if "View" in cols:
return
cols["View"] = cols.pop("Perspective")
cols["Max"] = cols.pop("Maximum")
# NOTE: user may not have changed these widths in API 6
try:
cols["View"] = cols.pop("Perspective")
cols["Max"] = cols.pop("Maximum")
except Exception:
pass
write_json(j, res)

View File

@ -72,6 +72,7 @@ class ServerTreeView(ContextMixin, TreeView): # type: ignore
logger.critical(e)
valid_json = False
# NOTE: reasonable defaults for long columns
width_map = {
"Name": 800,
"Map": 300,
@ -96,8 +97,9 @@ class ServerTreeView(ContextMixin, TreeView): # type: ignore
column.set_fixed_width(saved_size)
column.set_expand(True)
else:
w = width_map[column_title]
column.set_fixed_width(w)
if column_title in width_map:
w = width_map[column_title]
column.set_fixed_width(w)
if column_title == "Ping":
column.set_cell_data_func(renderer, self._get_ping)