Created
December 15, 2016 16:34
-
-
Save entrypointkr/b534e6d97477065553aa08cb12581fdc to your computer and use it in GitHub Desktop.
CommandHelper TabAutoComplete
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@key = 'registered_aliases'; | |
@prevAliases = get_value(@key); | |
# Ensure | |
if (!@prevAliases) { | |
@prevAliases = array(); | |
} | |
set_timeout(0, closure() { | |
@completes = array(); | |
foreach (@alias in get_aliases()) { | |
@name = substr( | |
@alias, | |
string_position(@alias, '/') + 1, | |
string_position(@alias, ' ') | |
); | |
if (!array_contains(@prevAliases, @name)) { | |
register_command(@name, array( | |
'tabcompleter': closure() {} | |
)); | |
} | |
array_push(@completes, @name); | |
} | |
foreach (@name in @prevAliases) { | |
if (!array_contains(@completes, @name)) { | |
unregister_command(@name); | |
} | |
} | |
store_value(@key, @completes); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment