Skip to content

Commit 942c386

Browse files
authored
Merge pull request #109 from LuCEresearchlab/highlight-big-cluster-support
Updated key handling for bigger clusters in ClusterView keybindings
2 parents 9e6fc02 + 8bbb32e commit 942c386

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

frontend/src/components/v2/tagger_component/ClusterView.tsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ interface Input {
3737
dispatchTaggingClusterSession: React.Dispatch<TaggingClusterSessionDispatch>
3838
}
3939

40-
const regExp = new RegExp(/^[1-9]h[1-9](:?-[1-9]\d*)?$/)
40+
const sep: string = 'h'
41+
const regExp = new RegExp(/^[1-9]\d*h[1-9](:?-[1-9]\d*)?$/)
4142

4243
function ClusterView({taggingClusterSession, dispatchTaggingClusterSession}: Input) {
4344

@@ -144,9 +145,9 @@ function ClusterItem({answer, taggingClusterSession, dispatchTaggingClusterSessi
144145

145146

146147
withKeyboard((command: string) => {
147-
if (command.startsWith("" + displayKey) && regExp.test(command)) {
148+
if (command.startsWith("" + displayKey + sep) && regExp.test(command)) {
148149
if (command.indexOf('-') == -1) {
149-
const from: number = parseInt(command.slice(2)) - 1
150+
const from: number = parseInt(command.slice(('' + displayKey).length + 1)) - 1
150151

151152
if (isNaN(from)) return
152153

@@ -162,7 +163,7 @@ function ClusterItem({answer, taggingClusterSession, dispatchTaggingClusterSessi
162163
})
163164
} else {
164165
const split_index: number = command.indexOf('-')
165-
const from: number = parseInt(command.slice(2, split_index)) - 1
166+
const from: number = parseInt(command.slice(('' + displayKey).length + 1, split_index)) - 1
166167
const to: number = parseInt(command.slice(split_index + 1))
167168

168169
if (isNaN(from) || isNaN(to)) return

0 commit comments

Comments
 (0)