Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filetypes duplicates when you set filetype #3186

Open
dustdfg opened this issue Mar 17, 2024 · 1 comment
Open

Filetypes duplicates when you set filetype #3186

dustdfg opened this issue Mar 17, 2024 · 1 comment

Comments

@dustdfg
Copy link
Contributor

dustdfg commented Mar 17, 2024

Description of the problem or steps to reproduce

TL;DR it is not a problem of the filetype but almost about reloading and solvable by #3062

When I use set filetype <filetype> the auto-completion duplicate names

  1. Open micro
  2. Write set filetype
  3. Press tab
  4. Press enter
  5. Write again set filetype
  6. Press tab again

screen-1710697530

Roots of the problem

Firstly I thought problem in

func colorschemeComplete(input string) (string, []string) {
var suggestions []string
files := config.ListRuntimeFiles(config.RTColorscheme)
for _, f := range files {
if strings.HasPrefix(f.Name(), input) {
suggestions = append(suggestions, f.Name())
}
}
var chosen string
if len(suggestions) == 1 {
chosen = suggestions[0]
}
return chosen, suggestions
}
// filetypeComplete autocompletes filetype
func filetypeComplete(input string) (string, []string) {
var suggestions []string
for _, f := range config.ListRuntimeFiles(config.RTSyntax) {
if strings.HasPrefix(f.Name(), input) {
suggestions = append(suggestions, f.Name())
}
}
var chosen string
if len(suggestions) == 1 {
chosen = suggestions[0]
}
return chosen, suggestions
}

But then I realized that code for color schemes auto-completion is the same as for filetype auto-completion.
switch inputOpt {
case "colorscheme":
_, suggestions = colorschemeComplete(input)
case "filetype":
_, suggestions = filetypeComplete(input)

They even used both in the same way so the problem not in the action/infocomplete.go

The problem is somewhere inside the buffer.SetOption function which tries to make reload

} else if option == "filetype" {
config.InitRuntimeFiles()
err := config.ReadSettings()
if err != nil {
screen.TermMessage(err)
}
err = config.InitGlobalSettings()
if err != nil {
screen.TermMessage(err)
}
config.InitLocalSettings(b.Settings, b.Path)
b.UpdateRules()

Specifications

Version: 2.0.14-dev.77
Commit hash: 5ae2799
OS: debian 12/testing
Terminal: foot

@dustdfg
Copy link
Contributor Author

dustdfg commented Mar 17, 2024

One more reason to test that PR :)

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

No branches or pull requests

1 participant