Skip to content
This repository was archived by the owner on Nov 26, 2023. It is now read-only.
This repository was archived by the owner on Nov 26, 2023. It is now read-only.

Breaks when pressing <delete> on empty query #31

@pmf-ids

Description

@pmf-ids

When calling jiq with

echo 1 | jiq

it opens up fine, displaying

[jq]> .

1

with the cursor being next to the dot. Hitting backspace removes the dot (which is expected behaviour). Hitting backspace again does nothing (also as expected). Now, hitting delete makes jiq crash with the message

panic: runtime error: slice bounds out of range [1:0]

goroutine 1 [running]:
github.com/fiatjaf/jiq.(*Query).Delete(0xc0002a6030, 0x0, 0x0, 0x0, 0x0)
	/home/fiatjaf/comp/jiq/query.go:58 +0x238
github.com/fiatjaf/jiq.(*Engine).Run(0xc0002d2000, 0x0)
	/home/fiatjaf/comp/jiq/engine.go:126 +0xaa8
main.run(0xc0002d2000, 0xc0002a6000, 0xc00028c1f0)
	/home/fiatjaf/comp/jiq/cmd/jiq/jiq.go:59 +0x32
main.main()
	/home/fiatjaf/comp/jiq/cmd/jiq/jiq.go:55 +0x18d

This does not happen when hitting delete while the dot (or any other filter) is still visible.

Tested on jiq version 0.7.1-3-g5dec899

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions