|
@@ -22,6 +22,7 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.ui.input;
|
24
|
24
|
|
|
25
|
+import com.dmdirc.commandparser.CommandArguments;
|
25
|
26
|
import com.dmdirc.commandparser.CommandInfo;
|
26
|
27
|
import com.dmdirc.commandparser.CommandManager;
|
27
|
28
|
import com.dmdirc.commandparser.commands.ChannelCommand;
|
|
@@ -224,7 +225,8 @@ public final class TabCompleter implements Serializable {
|
224
|
225
|
targets.include(TabCompletionType.COMMAND);
|
225
|
226
|
return targets;
|
226
|
227
|
} else {
|
227
|
|
- return getIntelligentResults(previousArgs.subList(offset, previousArgs.size()));
|
|
228
|
+ return getIntelligentResults(
|
|
229
|
+ new CommandArguments(previousArgs.subList(offset, previousArgs.size())));
|
228
|
230
|
}
|
229
|
231
|
}
|
230
|
232
|
|
|
@@ -232,23 +234,24 @@ public final class TabCompleter implements Serializable {
|
232
|
234
|
* Retrieves the intelligent results for the command and its arguments
|
233
|
235
|
* formed from args.
|
234
|
236
|
*
|
235
|
|
- * @param args A list of "words" in the input
|
|
237
|
+ * @param args The input arguments
|
236
|
238
|
* @return Additional tab targets for the text, or null if none are available
|
237
|
239
|
*/
|
238
|
|
- private static AdditionalTabTargets getIntelligentResults(final List<String> args) {
|
239
|
|
- if (args.isEmpty() || args.get(0).charAt(0) != CommandManager.getCommandChar()) {
|
|
240
|
+ private static AdditionalTabTargets getIntelligentResults(final CommandArguments args) {
|
|
241
|
+ if (!args.isCommand()) {
|
240
|
242
|
return null;
|
241
|
243
|
}
|
242
|
244
|
|
243
|
|
- final String signature = args.get(0).substring(1);
|
244
|
|
- final Map.Entry<CommandInfo, Command> command = CommandManager.getCommand(signature);
|
|
245
|
+ final Map.Entry<CommandInfo, Command> command
|
|
246
|
+ = CommandManager.getCommand(args.getCommandName());
|
245
|
247
|
|
246
|
248
|
AdditionalTabTargets targets = null;
|
247
|
249
|
|
248
|
250
|
if (command != null) {
|
249
|
251
|
if (command.getValue() instanceof IntelligentCommand) {
|
250
|
252
|
targets = ((IntelligentCommand) command.getValue())
|
251
|
|
- .getSuggestions(args.size() - 1, args.subList(1, args.size()));
|
|
253
|
+ .getSuggestions(args.getArguments().length,
|
|
254
|
+ Arrays.asList(args.getArgumentsAsString()));
|
252
|
255
|
}
|
253
|
256
|
|
254
|
257
|
if (command.getValue() instanceof ChannelCommand) {
|
|
@@ -270,6 +273,6 @@ public final class TabCompleter implements Serializable {
|
270
|
273
|
* @return Additional tab targets for the text, or null if none are available
|
271
|
274
|
*/
|
272
|
275
|
public static AdditionalTabTargets getIntelligentResults(final String text) {
|
273
|
|
- return getIntelligentResults(Arrays.asList(text.split(" ")));
|
|
276
|
+ return getIntelligentResults(new CommandArguments(text));
|
274
|
277
|
}
|
275
|
278
|
}
|