|
@@ -22,6 +22,8 @@
|
22
|
22
|
|
23
|
23
|
package com.dmdirc.addons.tabcompletion_mirc;
|
24
|
24
|
|
|
25
|
+import com.google.common.collect.Lists;
|
|
26
|
+
|
25
|
27
|
import com.dmdirc.Channel;
|
26
|
28
|
import com.dmdirc.FrameContainer;
|
27
|
29
|
import com.dmdirc.ui.input.AdditionalTabTargets;
|
|
@@ -32,6 +34,7 @@ import com.dmdirc.ui.input.tabstyles.TabCompletionStyle;
|
32
|
34
|
|
33
|
35
|
import java.awt.Toolkit;
|
34
|
36
|
import java.util.Collections;
|
|
37
|
+import java.util.List;
|
35
|
38
|
|
36
|
39
|
public class MircStyle implements TabCompletionStyle {
|
37
|
40
|
|
|
@@ -64,27 +67,27 @@ public class MircStyle implements TabCompletionStyle {
|
64
|
67
|
final String target;
|
65
|
68
|
if (word.equals(lastWord)) {
|
66
|
69
|
final TabCompletionMatches res = tabCompleter.complete(tabString, additional);
|
67
|
|
- Collections.sort(res.getResults(), String.CASE_INSENSITIVE_ORDER);
|
|
70
|
+ final List<String> results = Lists.newArrayList(res.getResults());
|
|
71
|
+ Collections.sort(results, String.CASE_INSENSITIVE_ORDER);
|
68
|
72
|
// We're continuing to tab through
|
69
|
|
- target = res.getResults().get((res.getResults().indexOf(lastWord) + (shiftPressed ? -1
|
70
|
|
- : 1) + res.getResults().size()) % res
|
71
|
|
- .getResults().size());
|
|
73
|
+ target = results.get((results.indexOf(lastWord) + (shiftPressed ? -1: 1) + results.size()) % results.size());
|
72
|
74
|
} else {
|
73
|
75
|
// New tab target
|
74
|
76
|
final TabCompletionMatches res = tabCompleter.complete(word, additional);
|
|
77
|
+ final List<String> results = Lists.newArrayList(res.getResults());
|
75
|
78
|
|
76
|
79
|
if (res.getResultCount() == 0) {
|
77
|
80
|
Toolkit.getDefaultToolkit().beep();
|
78
|
81
|
return null;
|
79
|
82
|
} else {
|
80
|
|
- Collections.sort(res.getResults(), String.CASE_INSENSITIVE_ORDER);
|
|
83
|
+ Collections.sort(results, String.CASE_INSENSITIVE_ORDER);
|
81
|
84
|
|
82
|
85
|
if (!word.isEmpty() && window instanceof Channel
|
83
|
86
|
&& ((Channel) window)
|
84
|
87
|
.getChannelInfo().getName().startsWith(word)) {
|
85
|
88
|
target = ((Channel) window).getChannelInfo().getName();
|
86
|
89
|
} else {
|
87
|
|
- target = res.getResults().get(0);
|
|
90
|
+ target = results.get(0);
|
88
|
91
|
}
|
89
|
92
|
tabString = word;
|
90
|
93
|
}
|