Skip to content

x/term: does not recognize delete key #76826

@josharian

Description

@josharian

terminal.ReadLine() does not recognize the forward-delete key escape sequence \x1b[3~; it gets silently discarded, which makes the readline experience weird for folks who use the delete key.

Reproduce, as of x/term at 3863673230bd2f654d5c3749dc90e6d130067dd6:

package main

import (
	"fmt"
	"os"

	"golang.org/x/term"
)

func main() {
	s, err := term.MakeRaw(int(os.Stdin.Fd()))
	if err != nil {
		panic(err)
	}
	defer term.Restore(int(os.Stdin.Fd()), s)

	t := term.NewTerminal(os.Stdin, "> ")

	fmt.Fprintln(t, "type text, try out delete/backspace, hit enter at end of line to exit:")
	t.ReadLine()
}

I'm willing to fix, if somone will review. (I don't see an owner at https://dev.golang.org/owners.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugReportIssues describing a possible bug in the Go implementation.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions