Skip to content

"Ghost cursor" artifact left behind after user types a line on Windows 10 #155

Open

Description

@shueybubbles

I'm evaluating line input modules to use for my Golang version of sqlcmd (github.com/microsoft/go-sqlcmd)
So far liner looks like a good candidate except for this display glitch. I can't tell if it's a Windows problem or an issue with the module. When my process exits the ghost cursor images disappear.

  • Operating System (eg. Windows, Linux, Mac)
    WINDOWS 10
  • Terminal Emulator (eg. xterm, gnome-terminal, konsole, ConEmu, Terminal.app, Command Prompt)
    Command Prompt
  • Bug behaviour
    Liner leaves behind a static cursor image on the first character of input
  • Expected behaviour
    No such distracting artifacts
  • Complete sample that reproduces the bug
package main

import (
	"fmt"

	"github.com/peterh/liner"
)

func main() {
	line := liner.NewLiner()
	defer line.Close()
	text := ""
	var err error
	for text != "q" {
		text, err = line.Prompt("Prompt:")
		if err == nil {
			fmt.Println("You typed:" + text)
		}
	}
}

image

image

Activity

  1. peterh commented on Mar 8, 2022

    @peterh
    Owner

    Liner doesn't draw the cursor, it is up to the Windows Console (or terminal emulator on other platforms) to draw the cursor.

    I use a program built with Liner on Windows every day. I don't recall seeing that particular issue in the past few years, but I switched from "Command Prompt" (aka "Windows Console") to "Windows Terminal" as soon as it became available. (You can get Windows Terminal from the Windows Store, and I believe Windows Terminal is the default on Windows 11), and my Windows Terminal configuration uses a block cursor instead of the underline cursor shown in your screenshot.

  2. shueybubbles commented on May 20, 2022

    @shueybubbles
    Author

    @peterh I have another report of my app causing the bash window on a Mac to behave oddly after the app exits.
    The issue they opened is microsoft/go-sqlcmd#87
    "but go-sqlcmd still makes bash shell command line behave erratically after exiting sqlcmd."

    Might you have a few minutes to look at our use of liner to make sure we're not using it in some obviously incorrect manner? Our wrapper class for it is at https://github.com/microsoft/go-sqlcmd/blob/e3972914801bc3492b49b6fe642a7e931e088be3/pkg/console/console.go#L24

    There are probably several other go packages I could replace it with for reading lines but picking from the vast set to land on one that meets all our needs can take a while, so I'm hoping I can get liner to work.

  3. shueybubbles commented on May 20, 2022

    @shueybubbles
    Author

    Would forgetting to call Close() before exiting the process cause any such issues in a shell?

  4. peterh commented on May 21, 2022

    @peterh
    Owner

    Would forgetting to call Close() before exiting the process cause any such issues in a shell?

    Yes. You must call Close() or the tty will be left in an indeterminate state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions