Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion schemas/bindings.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@
"type": "string"
},
"delimiter": {
"type": "string"
"type": "string",
"minLength": 1,
"maxLength": 1
},
"eval": {
"type": "boolean"
Expand Down
4 changes: 3 additions & 1 deletion schemas/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
"type": "object",
"properties": {
"outputDelimiter": {
"type": "string"
"type": "string",
"minLength": 1,
"maxLength": 1
},
"timeout": {
"type": "integer",
Expand Down
8 changes: 4 additions & 4 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion src/widget.eta
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down