Skip to content

Conversation

@raccoonback
Copy link

We tried to use Emoji, but we found that each row in the completion area was pushed back as shown in the following issue.

Related issue: #209

# Error case
md > 
           🎨    Store the username and age             
                ⚡️  Store the article text posted by user  
                   🔥    Store the text commented to articles   
                        🐛    Store the text commented to articles   
                             ✨    Store the text commented to articles   
                                 📝    Store the text commented to articles   

# Solved case
md > 🚧
      🎉    Store the text commented to articles   
      ✅    Store the text commented to articles   
      🔒    Store the text commented to articles   
      🔖    Store the text commented to articles   
      🚨    Store the text commented to articles   
      🚧    Store the text commented to articles   

Therefore, I applied carriage return to specify the initial cursor of all rows at the column interval of the initial cursor.

In addition, we applied carriage return before moving the prefix to the current cursor column, so that the prefix does not look redundant.

# init state
abcdefghi > 
             🎉    Store the text commented to articles   
             ✅    Store the text commented to articles   
             🔒    Store the text commented to articles   
             🔖    Store the text commented to articles   
             🚨    Store the text commented to articles   
             🚧    Store the text commented to articles   

# error case
aabcdefghi > 🌱        // The 'a' of old prefix  remains.
             🥅    Store the text commented to articles   
             🚩    Store the text commented to articles   
             🌱    Store the text commented to articles   
             🏷     Store the text commented to articles   
             🔍    Store the text commented to articles   
             ⚗     Store the text commented to articles   

@raccoonback
Copy link
Author

You can test it with the code below.

package main

import (
	"fmt"
	"github.com/c-bata/go-prompt"
)

func completer(d prompt.Document) []prompt.Suggest {
	s := []prompt.Suggest{
		{Text: "🎨", Description: "Store the username and age"},
		{Text: "⚡️", Description: "Store the article text posted by user"},
		{Text: "🔥", Description: "Store the text commented to articles"},
		{Text: "🐛", Description: "Store the text commented to articles"},
		{Text: "✨", Description: "Store the text commented to articles"},
		{Text: "📝", Description: "Store the text commented to articles"},
		{Text: "🚀", Description: "Store the text commented to articles"},
		{Text: "💄", Description: "Store the text commented to articles"},
		{Text: "🎉", Description: "Store the text commented to articles"},
		{Text: "✅", Description: "Store the text commented to articles"},
		{Text: "🔒", Description: "Store the text commented to articles"},
		{Text: "🔖", Description: "Store the text commented to articles"},
		{Text: "🚨", Description: "Store the text commented to articles"},
		{Text: "🚧", Description: "Store the text commented to articles"},
		{Text: "💚", Description: "Store the text commented to articles"},
		{Text: "⬇", Description: "Store the text commented to articles"},
		{Text: "⬆", Description: "Store the text commented to articles"},
		{Text: "📌", Description: "Store the text commented to articles"},
		{Text: "👷", Description: "Store the text commented to articles"},
		{Text: "📈", Description: "Store the text commented to articles"},
		{Text: "♻", Description: "Store the text commented to articles"},
		{Text: "➕", Description: "Store the text commented to articles"},
		{Text: "➖", Description: "Store the text commented to articles"},
		{Text: "🔧", Description: "Store the text commented to articles"},
		{Text: "🌐", Description: "Store the text commented to articles"},
		//
		{Text: "✏️", Description: "Store the text commented to articles"},
		{Text: "💩", Description: "Store the text commented to articles"},
		{Text: "⏪", Description: "Store the text commented to articles"},
		{Text: "📦", Description: "Store the text commented to articles"},
		{Text: "👽", Description: "Store the text commented to articles"},
		{Text: "🚚", Description: "Store the text commented to articles"},
		{Text: "💥", Description: "Store the text commented to articles"},
		{Text: "♿", Description: "Store the text commented to articles"},
		{Text: "🍱", Description: "Store the text commented to articles"},
		{Text: "💡", Description: "Store the text commented to articles"},
		{Text: "💬", Description: "Store the text commented to articles"},
		{Text: "🗑️", Description: "Store the text commented to articles"},
		{Text: "💫", Description: "Store the text commented to articles"},
		{Text: "🥅", Description: "Store the text commented to articles"},
		{Text: "🚩", Description: "Store the text commented to articles"},
		{Text: "🌱", Description: "Store the text commented to articles"},
		{Text: "🏷", Description: "Store the text commented to articles"},
		{Text: "🔍", Description: "Store the text commented to articles"},
		{Text: "⚗", Description: "Store the text commented to articles"},
		{Text: "📸", Description: "Store the text commented to articles"},
		{Text: "🙈", Description: "Store the text commented to articles"},
		{Text: "🥚", Description: "Store the text commented to articles"},
		{Text: "🤡", Description: "Store the text commented to articles"},
		{Text: "📱", Description: "Store the text commented to articles"},
		{Text: "🏗", Description: "Store the text commented to articles"},
		{Text: "🚸", Description: "Store the text commented to articles"},
		{Text: "👥", Description: "Store the text commented to articles"},
		{Text: "🔇", Description: "Store the text commented to articles"},
		{Text: "🔊", Description: "Store the text commented to articles"},
		{Text: "🗃", Description: "Store the text commented to articles"},
		{Text: "💬", Description: "Store the text commented to articles"},
		{Text: "🍻", Description: "Store the text commented to articles"},
		{Text: "💡", Description: "Store the text commented to articles"},
		{Text: "♿", Description: "Store the text commented to articles"},
		{Text: "📄", Description: "Store the text commented to articles"},
	}
	return prompt.FilterHasPrefix(s, d.GetWordBeforeCursor(), true)
}

func main() {
	fmt.Println("Please select table.")
	t := prompt.Input("abcdefgi > ", completer, prompt.OptionShowCompletionAtStart(),
		prompt.OptionCompletionOnDown(),)
	fmt.Println("You selected " + t)
}

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant