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

Append newline to autocomplete input if it's missing (fixes #303) #304

Merged
merged 3 commits into from
Apr 9, 2024

Conversation

MarvinJWendt
Copy link
Contributor

This fixes #303 by appending a newline to the autocomplete file input when it is missing.
The fix is tested and seems to work.

@MarvinJWendt
Copy link
Contributor Author

MarvinJWendt commented Apr 8, 2024

Offtopic

While browsing trough the code, I found this variable in the same file, which is instantly overwritten:
image

Maybe worth to remove the first assignment.

@MarvinJWendt
Copy link
Contributor Author

MarvinJWendt commented Apr 8, 2024

Test input

This file can be used to test the autocomplete:
state.json

It's missing the \n at the end.

Sometimes it's hard to reproduce, as many IDEs put a \n at the end of files automatically when saving (which isn't visible, as only \n\n will create a new visual line).

@antonmedv
Copy link
Owner

Yes, var is not needed)

internal/complete/complete.go Outdated Show resolved Hide resolved
if input[len(input)-1] != '\n' {
input = append(input, '\n')
}
// Append newline to make sure that input is valid.
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

=) comment is wrong. new line is needed to not glue with next peace of code. also ; will work too

@antonmedv antonmedv merged commit 433854d into antonmedv:master Apr 9, 2024
2 checks passed
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.

No autocomplete in zsh when JSON doesn't end with a new line
2 participants