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

✨ Add -n option to prevent newline after emoji #12

Merged
merged 4 commits into from Sep 27, 2022

Conversation

nobodyinperson
Copy link
Contributor

This Merge Request add the bemoji -n option to not include a newline character after the selected emoji.

A newline after the emoji might or might not be wanted, which this option the user can choose.

In my case I don't want the newline as pasting it into xfce4-terminal a warning is shown whenever pasting something with newlines in it.

Copy link
Owner

@marty-oehme marty-oehme left a comment

Choose a reason for hiding this comment

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

I like the idea and the code implementation looks really good to me!

But now that I am looking over the whole picture - I am wondering if there is actually a time when we do want to paste the newline character as well?

I can't really think of a situation where we want both the emoji and a newline character after (that could not be solved by paste and pressing enter). Perhaps your implemented behaviour should actually be the only or at least default one.

bemoji Outdated Show resolved Hide resolved
bemoji Show resolved Hide resolved
@nobodyinperson
Copy link
Contributor Author

I also tried to add a BATS test for this new -n option. But funnily enough, BATS does not seem to be designed for this: assert_output ignores the trailing newline and assert_output --regex '^❤️$' fails for some reason 🤷

@nobodyinperson
Copy link
Contributor Author

As for the default behaviour: I'd rather keep bemoji backwards-compatible and make -n opt-in as it is in this implementation. Although I can't imagine a situation where one would want a trailing newline either 😅

@marty-oehme
Copy link
Owner

I also tried to add a BATS test for this new -n option. But funnily enough, BATS does not seem to be designed for this: assert_output ignores the trailing newline and assert_output --regex '^❤️$' fails for some reason 🤷

This is a good point, I remember having trouble with the bats regexes in some other tests. You probably have this correct but just wanna point it out nonetheless, the option is --regexp.

Anyway, I think it's an option that would be really worth to have a little test for, I'll also see how we could implement it over the coming days!

@marty-oehme
Copy link
Owner

Well, after quite a bit of fiddling I managed to make the tests work. Turns out we have to invoke the tests with run --keep-empty-lines for it to work. This seems to be due to an old bug in bats which is now taken care of with the commandline option.

This now looks good as is - though I'm still not fully convinced of the necessity to keep the old behavior if we both can't think of any newline containing use case.

Added simple documentation for option in the project's markdown README
file, and add a quick line in changelog additions.
@marty-oehme
Copy link
Owner

I added some quick documentation.

@nobodyinperson I think this looks good now and if you agree I'm finally ready to merge! :)

@nobodyinperson
Copy link
Contributor Author

Looks good to me 👍

@marty-oehme marty-oehme merged commit d03068d into marty-oehme:main Sep 27, 2022
@nobodyinperson nobodyinperson deleted the no-newline-after-emoji branch September 28, 2022 08:26
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.

None yet

2 participants