diff --git a/schemas/bindings.json b/schemas/bindings.json index 7b0c3c8..313c457 100644 --- a/schemas/bindings.json +++ b/schemas/bindings.json @@ -34,7 +34,9 @@ "type": "string" }, "delimiter": { - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 1 }, "eval": { "type": "boolean" diff --git a/schemas/config.json b/schemas/config.json index a9f47b5..929b860 100644 --- a/schemas/config.json +++ b/schemas/config.json @@ -2,7 +2,9 @@ "type": "object", "properties": { "outputDelimiter": { - "type": "string" + "type": "string", + "minLength": 1, + "maxLength": 1 }, "timeout": { "type": "integer", diff --git a/src/run.ts b/src/run.ts index a2c0505..6dfb349 100644 --- a/src/run.ts +++ b/src/run.ts @@ -84,22 +84,22 @@ For example, this simulates pressing "g", "p", and "f".`, tui.close() - const outputs = [buffer] + const delimiter = typeof definedDelimiter === 'string' ? definedDelimiter : ctx.outputDelimiter + + const outputs = [delimiter, buffer] for (const [k, v] of Object.entries(rest)) { switch (typeof v) { case 'string': outputs.push(`${k}:${v}`) break case 'boolean': - outputs.push(`${k}:${JSON.stringify(v)}`) + outputs.push(`${k}:${v ? 'true' : 'false'}`) break default: break } } - const delimiter = typeof definedDelimiter === 'string' ? definedDelimiter : ctx.outputDelimiter - console.log(outputs.join(delimiter)) } catch (e: unknown) { if (e instanceof AbortError) { diff --git a/src/widget.eta b/src/widget.eta index b82b6f8..4f9097d 100644 --- a/src/widget.eta +++ b/src/widget.eta @@ -28,7 +28,10 @@ _wk_widget() { ;; esac - reply=("${(@ps:\t:)res}") + # `p` flag does NOT work with the ${var} format; must use $var instead. + # See: https://zsh.sourceforge.io/Doc/Release/Expansion.html#Parameter-Expansion + local delimiter=$res[1] + reply=("${(@ps:$delimiter:)${res:2}}") if [[ "${reply[(rb:2:)eval:*]}" == 'eval:true' ]]; then BUFFER="${LBUFFER}${(e)reply[1]}${RBUFFER}"