Carpet

Carpet

2M Downloads

[scarpet] Can't make argument suggestions from dynamic global_

dj-foxxy opened this issue ยท 1 comments

commented

Suggesters don't see changes to global_s so the suggester is always blank. The app demonstrates the issue:

global_suggestions = [];

__config() -> {
  'commands' -> {
    'suggest <suggestion>' -> 'noop',
    'suggest_wrapped <suggestion_wrapped>' -> 'noop',
    'add <string>' -> 'add_suggestion',
    'get' -> 'get_suggestions'
  },
  'arguments' -> {
    'suggestion' -> {
      'type' -> 'string',
      'suggester' -> _(args) -> global_suggestions
    },
    'suggestion_wrapped' -> {
      'type' -> 'string',
      'suggester' -> _(args) -> suggester()
    }
  }
};

suggester() -> global_suggestions;

noop(arg) -> null;
add_suggestion(suggestion) -> global_suggestions += suggestion;
get_suggestions() -> print(global_suggestions);
/script load myapp
/myapp get
[]
/myapp add foo
/myapp get
[foo]
// Does not suggest foo in next two lines
/myapp suggest
/myapp suggest_wrapped
commented

Thanks @gnembon