Skip to content

Pasting stops at around line 257 if pasting more than 257 lines #3084

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

Closed
phanski opened this issue Apr 7, 2019 · 4 comments
Closed

Pasting stops at around line 257 if pasting more than 257 lines #3084

phanski opened this issue Apr 7, 2019 · 4 comments

Comments

@phanski
Copy link

phanski commented Apr 7, 2019

I'm trying to paste this: https://pastebin.com/jdaM8FKG and everytime it stops pasting at around line 257. I've changed the maxClipboard value but it did nothing.

@SpaceBeeGaming
Copy link

You can use the built-in Pastebin program. Add internet card to the computer =>
use command pastebin get <code> <filename>

@payonel
Copy link
Member

payonel commented Jun 6, 2019

@NiamiTV you've found an interesting problem in our code with clipboard events

  1. we have a maxClipboard setting in the config that is intended to limit the size of the string you can send via clipboard. This is done to limit the packet size load from clients to servers. However, this setting was never used, and is by default 1024. To actually start using this limit would definitely cause a lot more grief that trouble it would solve, as 1024 chars is a very restricted clipboard, and our users have enjoyed no such limit this entire time. I have thus opted to removed this setting in our config.
  2. Our code does break up very large clipboard messages from clients to servers, and puts a delay on sending each part, but does send all of the parts. This code is working and shall remain
  3. On the server side, we buffer the clipboard parts as signals in the "computer signal queue". The running machine state (the computer) pulls the signals, and openos seeing the "clipboard" events, pastes the text into your file you have open for edit. However,
    3.a) the clipboard text is broken in lines, and each line is put into its own clipboard signal. Your example file is 1331 lines long, and thus would generate 1331 "clipboard" events
    3.b) our machine signal queue handler is hard coded to limit the number of queued signals at 256.

And bam, you have the 256 line limit issue. Sometimes (most times?) you see 257 because machine state wakes up soon enough to get at least 1 of the signals before the queue is maxed out, discarding the remaining 1074 lines.

I tested creating clipboard events that pack more than a single line of text. This mitigates part of the problem, but it is also possible that such a solution could cause unanticipated side affects in the community that isn't expecting this change in clipboard data

I have decided to pull out the hard coded value of 256 for our max queue size, and put that in our configuration. It will default to 256 so as to not interfere with what the community has come to expect. Thus, with the fix for this bug, if you wanted to paste such a large file, you'd want to change the oc config on the server, and change computer.maxSignalQueueSize from its default 256 to something more like 2048

The alternative solution is to download the file in-game, such as by using the pastebin tool @SpaceBeeGaming suggested.

@payonel payonel closed this as completed in 0de0bf2 Jun 6, 2019
@Cre8or
Copy link

Cre8or commented Aug 27, 2022

I know this is an old (and closed) issue, but I suspect the fix described by @payonel is not working as intended.

# text of this many lines. The default (and minimum) is 256

If I understand this correctly, the intention is for maxSignalQueueSize to be at least 256. Clients shall be able to increase this limit to a higher value (which corresponds to what Payonel described in the comment above).

However, in my modpack, I've been unable to increase this limit beyond the default value. I've tried pasting a file with ~300 lines and the insertion stopped at 256. It would seem that this is because, in the code implementation, the limit is calculated using min instead of max:

val maxSignalQueueSize: Int = (if (config.hasPath("computer.maxSignalQueueSize")) config.getInt("computer.maxSignalQueueSize") else 256) min 256

The end of this line should probably read:

[...] config.getInt("computer.maxSignalQueueSize") else 256) max 256 

...so that the greater value of the two is used.

I'll attempt to fix this myself for my modpack (for personal use only!), but still wanted to bring this up to your attention so it can be resolved in future releases. And sorry for the issue bump. 😄

@payonel
Copy link
Member

payonel commented Aug 27, 2022

There is something about putting the operator/function name min or max between two numbers that I really dislike about scala. I'm probably the only one that makes this mistake. Thanks @Cre8or

@payonel payonel reopened this Aug 27, 2022
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

4 participants