|
@@ -32,15 +32,14 @@ import com.dmdirc.ui.interfaces.InputWindow;
|
32
|
32
|
|
33
|
33
|
import java.awt.Toolkit;
|
34
|
34
|
import java.util.Collections;
|
35
|
|
-import java.util.List;
|
36
|
35
|
|
37
|
36
|
public class MircStyle implements TabCompletionStyle {
|
38
|
37
|
|
39
|
|
- /** The last set of results we retrieved. */
|
40
|
|
- private List<String> lastResult;
|
41
|
|
-
|
42
|
38
|
/** The last word that was tab completed. */
|
43
|
39
|
private String lastWord;
|
|
40
|
+
|
|
41
|
+ /** The last string we tried to tab complete. */
|
|
42
|
+ private String tabString;
|
44
|
43
|
|
45
|
44
|
/** The tab completer that we use. */
|
46
|
45
|
protected final TabCompleter tabCompleter;
|
|
@@ -68,9 +67,12 @@ public class MircStyle implements TabCompletionStyle {
|
68
|
67
|
final String word = original.substring(start, end);
|
69
|
68
|
String target = "";
|
70
|
69
|
if (word.equals(lastWord)) {
|
|
70
|
+ final TabCompleterResult res = tabCompleter.complete(tabString, additional);
|
|
71
|
+ Collections.sort(res.getResults(), String.CASE_INSENSITIVE_ORDER);
|
71
|
72
|
// We're continuing to tab through
|
72
|
|
- target = lastResult.get((lastResult.indexOf(lastWord) +
|
73
|
|
- (shiftPressed ? -1 : 1) + lastResult.size()) % lastResult.size());
|
|
73
|
+ target = res.getResults().get((res.getResults().indexOf(lastWord) +
|
|
74
|
+ (shiftPressed ? -1 : 1) + res.getResults().size()) % res
|
|
75
|
+ .getResults().size());
|
74
|
76
|
} else {
|
75
|
77
|
// New tab target
|
76
|
78
|
final TabCompleterResult res = tabCompleter.complete(word, additional);
|
|
@@ -88,7 +90,7 @@ public class MircStyle implements TabCompletionStyle {
|
88
|
90
|
} else {
|
89
|
91
|
target = res.getResults().get(0);
|
90
|
92
|
}
|
91
|
|
- lastResult = res.getResults();
|
|
93
|
+ tabString = word;
|
92
|
94
|
}
|
93
|
95
|
}
|
94
|
96
|
|