Skip to content

Commit c2d52ca

Browse files
committed
options.py(fix[_show_option]): Handle bracketed array indices correctly
why: Querying 'status-format[0]' returned None because explode_arrays() transforms the key to 'status-format', losing the original indexed key. what: - Parse raw output first before exploding arrays - Direct lookup for indexed queries (key with brackets found in raw dict) - For base name queries, continue with explode_arrays transformation - Avoids duplicating regex parsing logic already in explode_arrays()
1 parent ec97859 commit c2d52ca

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

src/libtmux/options.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,15 +1146,16 @@ def _show_option(
11461146
if not len(options_output):
11471147
return None
11481148

1149-
output_exploded = convert_values(
1150-
explode_complex(
1151-
explode_arrays(
1152-
parse_options_to_dict(
1153-
io.StringIO("\n".join(cmd.stdout)),
1154-
),
1155-
),
1156-
),
1157-
)
1149+
# Parse raw output first (preserves indexed keys like "status-format[0]")
1150+
output_raw = parse_options_to_dict(io.StringIO("\n".join(cmd.stdout)))
1151+
1152+
# Direct lookup for indexed queries (e.g., "status-format[0]")
1153+
# tmux returns only that index's value, so we handle it before exploding
1154+
if option in output_raw:
1155+
return convert_value(output_raw[option])
1156+
1157+
# For base name queries, explode arrays and return structured data
1158+
output_exploded = convert_values(explode_complex(explode_arrays(output_raw)))
11581159

11591160
if not isinstance(output_exploded, (dict, SparseArray)):
11601161
return t.cast("ConvertedValue", output_exploded)

0 commit comments

Comments
 (0)