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

Make pasting warning appear when long pastes are going to be split into many lines #426

Merged
merged 2 commits into from Mar 8, 2016

Conversation

Projects
None yet
3 participants
@Manishearth
Contributor

Manishearth commented Feb 23, 2016

This can cause accidental channel floods when the message being pasted is longer
than you thought it was, but doesn't contain newlines (and will not trigger the
usual Ctrl-K/Ctrl-C pasting warning)

@@ -227,7 +230,7 @@ static void paste_buffer_join_lines(GArray *buf)
}
/* all looks fine - now remove the whitespace, but don't let lines
get longer than 400 chars */
get longer than LINE_SPLIT_LIMIT(400) chars */

This comment has been minimized.

@LemonBoy

LemonBoy Feb 23, 2016

Member

Do not mention the 400 in the comment here

number of lines obtained from this. The number isn't entirely accurate;
we just choose the greater of the two since the exact value isn't
important */
if (paste_buffer->len / LINE_SPLIT_LIMIT > paste_verify_line_count &&

This comment has been minimized.

@LemonBoy

LemonBoy Feb 23, 2016

Member

Have a temporary variable for paste_buffer->len / LINE_SPLIT_LIMIT

@@ -638,7 +653,8 @@ static gboolean paste_timeout(gpointer data)
{
paste_was_bracketed_mode = paste_bracketed_mode;
if (paste_line_count == 0) {
/* Take into account the fact that a line may be split every LINE_SPLIT_LIMIT characters */
if (paste_line_count == 0 && paste_buffer->len / LINE_SPLIT_LIMIT <= paste_verify_line_count) {

This comment has been minimized.

@LemonBoy

LemonBoy Feb 23, 2016

Member

I think this should be consolidated with another flag paste_have_lines (?)

This comment has been minimized.

@Manishearth

Manishearth Feb 23, 2016

Contributor

What would that flag do? I think sharing the verify length count is fine here, they become the same in the end anyway?

@Manishearth

This comment has been minimized.

Contributor

Manishearth commented Feb 23, 2016

Anything else we could do? I think that using the exact value for the line limit from irc-servers.c is more accurate, but unnecessary since this warning is mostly about figuring out if you're pasting something too big or too small.

@ailin-nemui

This comment has been minimized.

Contributor

ailin-nemui commented Feb 26, 2016

not all protocols require line splitting so the warning would be misleading in that case...

int split_lines = paste_buffer->len / LINE_SPLIT_LIMIT;
/* Take into account the fact that a line may be split every LINE_SPLIT_LIMIT characters */
if (paste_line_count == 0 && split_lines <= paste_verify_line_count) {

This comment has been minimized.

@ailin-nemui

ailin-nemui Mar 3, 2016

Contributor

I'm not this is correct. try pasting a very long line without linebreaks with and without your patch

This comment has been minimized.

@Manishearth

Manishearth Mar 4, 2016

Contributor

I'm not sure what you mean here; I've tested that (that's the entire point of this PR), it works. What is the undesired behavior that you're referring to?

This comment has been minimized.

@ailin-nemui

ailin-nemui Mar 4, 2016

Contributor

ok I see now sorry for the confusion

ailin-nemui added a commit that referenced this pull request Mar 8, 2016

Merge pull request #426 from Manishearth/paste-split
Make pasting warning appear when long pastes are going to be split into many lines

@ailin-nemui ailin-nemui merged commit 8f1f1d8 into irssi:master Mar 8, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Manishearth Manishearth deleted the Manishearth:paste-split branch Jan 5, 2017

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