You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
exportfunctionautocomplete(data,args){data.flags(argsSchema);constlastFlag=args.length>1 ? args[args.length-2] : null;if(lastFlag=="--spend-on")// Provide a couple auto-complete options to facilitate these arguments with spaces in themreturnpurchaseOptions.map(f=>f.replaceAll(" ","_")).concat(purchaseOptions.map(f=>`'${f}'`));return[];}
Today, this seems to work if and only if the user has started typing some characters in the next argument (then lastFlag is correct).
Where this falls apart, is if the user types e.g. --spend-on and then immediately hits "tab". In this case, the last flag is args[^-1], but we don't detect that correctly and merely return a list of flags.
Further, if they type an entire second arg, --spend-on -l then hit autocomplete, they start seeing the spend-on options.
Perhaps in older versions of the game, the args list always contained an empty arg at the end (or perhaps we just never tested this, although I could have sworn it worked before). In either event, we now need to detect whether the last arg is "complete", and use the last arg, rather than the second-to-last arg as the "lastFlag".
We may need to wrap this up in a helper function to make it easier to maintain future fixes.
The text was updated successfully, but these errors were encountered:
alainbryden
changed the title
autocomplete doesn't seem to work anymore
Custom Auto-Complete args don't work until the first character of the next argument is typed
Nov 27, 2024
Autocomplete has always worked like this:
Today, this seems to work if and only if the user has started typing some characters in the next argument (then lastFlag is correct).
Where this falls apart, is if the user types e.g.
--spend-on
and then immediately hits "tab". In this case, the last flag isargs[^-1]
, but we don't detect that correctly and merely return a list of flags.Further, if they type an entire second arg,
--spend-on -l
then hit autocomplete, they start seeing the spend-on options.Perhaps in older versions of the game, the args list always contained an empty arg at the end (or perhaps we just never tested this, although I could have sworn it worked before). In either event, we now need to detect whether the last arg is "complete", and use the last arg, rather than the second-to-last arg as the "lastFlag".
We may need to wrap this up in a helper function to make it easier to maintain future fixes.
The text was updated successfully, but these errors were encountered: