-
-
Notifications
You must be signed in to change notification settings - Fork 183
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
Truncate tags command clipboard text within 32k string limit #1546
Truncate tags command clipboard text within 32k string limit #1546
Conversation
Last commit published: 297c5cee1c93bb61f93d067837d7c1a1eaf49ede. PR PublishingThe artifacts published by this PR:
Repository DeclarationIn order to use the artifacts published by the PR, add the following repository to your buildscript: repositories {
maven {
name 'Maven for PR #1546' // https://github.com/neoforged/NeoForge/pull/1546
url 'https://prmaven.neoforged.net/NeoForge/pr1546'
content {
includeModule('net.neoforged', 'neoforge')
includeModule('net.neoforged', 'testframework')
}
}
} MDK installationIn order to setup a MDK using the latest PR version, run the following commands in a terminal. mkdir NeoForge-pr1546
cd NeoForge-pr1546
curl -L https://prmaven.neoforged.net/NeoForge/pr1546/net/neoforged/neoforge/21.3.38-beta-pr-1546-1.21.1-GH-1543-tags-command-clipboard-truncation/mdk-pr1546.zip -o mdk.zip
jar xf mdk.zip
rm mdk.zip || del mdk.zip To test a production environment, you can download the installer from here. |
One thought: Does this really need to run as a server command? Those registries are synced to the client, aren't they? |
Not necessarily -- afaik that command dumps tags for any registry, including server only ones? Registries can have tags and not be synced. |
This may be less elegant to look at and read, but it fits more into the 32.6k limit we (artificially) set for the clipboard text by actually measuring the text as we go add more elements, until no more can fit within the limit.
Updated to use a new truncation strategy that fits as much text as possible into the clipboard text, rather than constraining the amount of elements based on a precalculated heuristic on element lengths. See updated PR description for details. |
🚀 This PR has been released as NeoForge version |
This PR fixes #1543 by truncating the number of lines in the copy-to-clipboard text of the
/neoforge tags
command to as much entries as can fit within the (artificial) limit of 32.6k characters for elements (plus some allowance for the explanatory text for the truncation).Tested by modifying the
list
subcommand temporarily to have 30,000+ dummy entries (adding to the count and usingStream.concat
), and it works.A previous version of this PR artifically constrained the number of entries to 1,000 entries (approximately the number of 32-character-long entries that fits into 32,767--the limit of strings in
FriendlyByteBuf
--and rounded down the nearest hundreds). At @Technici4n's prompting (in Discord), I've changed the strategy to instead fit as much of the entries as possible by counting their lengths as they're added to the text, and cutting off when the text is about to reach a limit, which is current 32,600 characters. That leaves about ~167 characters room for the explanatory note for the truncation, which should be plenty.We could perhaps consider adding a new subcommand to
/neoforge dump
which exports the list of tags for registries (or elements in a tag, or tags of an element). Should that be added, we may also remove the functionality of the copy-on-clipboard for/neoforge tags
, and perhaps even have it instead give the appropriate/neoforge dump
command to the user with arguments filled in.