mirror of
https://github.com/Ark0N/Codeman.git
synced 2026-11-20 04:59:34 +01:00
Merge #821: a key table reduced to one binding is read from the full listing
tmux 3.7 to 3.7c print a one-binding list-keys -T answer as a status message instead of stdout; Codeman now falls back to the full list-keys listing.
This commit is contained in:
commit
5df5628518
6 files changed
+111
-9
No files matched your search
@@ -153,6 +153,16 @@ export function restrictTmuxPrefixTable(tmux: string, run: TmuxRunner = defaultR
|
||||
let listing: string | null;
|
||||
try {
|
||||
listing = run(`${tmux} list-keys -T prefix`);
|
||||
// ⚠️ Some tmux builds (a `next-3.7` development build) print NOTHING for
|
||||
// `list-keys -T prefix` when the table holds exactly one binding, which is the
|
||||
// shape this function leaves behind: read blank as "ask the full listing" and keep
|
||||
// only its prefix-table lines, or every call would reset an already-reduced table.
|
||||
if (!listing.trim()) {
|
||||
listing = run(`${tmux} list-keys`)
|
||||
.split('\n')
|
||||
.filter((line) => PREFIX_LINE.test(line.trim()))
|
||||
.join('\n');
|
||||
}
|
||||
} catch {
|
||||
listing = null; // an empty table makes list-keys fail on some tmux builds
|
||||
}
|
||||
|
||||
+15
-4
@@ -991,6 +991,19 @@ export class TuiClient {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* One key table as `list-keys` prints it. ⚠️ Some tmux builds (seen on a `next-3.7`
|
||||
* development build) print NOTHING for `list-keys -T <table>` when the table holds
|
||||
* exactly one binding, which is the shape Codeman reduces the prefix table to. So a
|
||||
* blank answer is retried as the full listing: every line there names its table,
|
||||
* and both parsers already filter on it.
|
||||
*/
|
||||
private async listKeyTable(table: TuiKeyTable): Promise<string> {
|
||||
const { stdout } = await this.exec('tmux', ['-L', this.socket, 'list-keys', '-T', table]);
|
||||
if (stdout.trim()) return stdout;
|
||||
return (await this.exec('tmux', ['-L', this.socket, 'list-keys'])).stdout;
|
||||
}
|
||||
|
||||
/**
|
||||
* The key that detaches, straight from tmux's own key table. Key tables are
|
||||
* server-global, so unlike the prefix this takes no session. A failure is
|
||||
@@ -998,8 +1011,7 @@ export class TuiClient {
|
||||
*/
|
||||
async readDetachKey(): Promise<string | null> {
|
||||
try {
|
||||
const { stdout } = await this.exec('tmux', ['-L', this.socket, 'list-keys', '-T', 'prefix']);
|
||||
return parseDetachKey(stdout);
|
||||
return parseDetachKey(await this.listKeyTable('prefix'));
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
@@ -1012,8 +1024,7 @@ export class TuiClient {
|
||||
*/
|
||||
async readPrefixBinding(key: string, table: TuiKeyTable = 'prefix'): Promise<string | null> {
|
||||
try {
|
||||
const { stdout } = await this.exec('tmux', ['-L', this.socket, 'list-keys', '-T', table]);
|
||||
return parsePrefixBinding(stdout, key, table);
|
||||
return parsePrefixBinding(await this.listKeyTable(table), key, table);
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user