Skip to content

Commit ce12111

Browse files
committed
feat(tpl): lookup backward for prefix match if shift is down
1 parent 08123b4 commit ce12111

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,6 @@ Specify PID file. PID will be written into the file on application startup.
328328
- ``, ``: move focus between file items
329329
- `Ctrl`/`Opt` + ``: move focus to first file item
330330
- `Ctrl`/`Opt` + ``: move focus to last file item
331-
- Repeat inputting same character will look for next file that prefixes with it.
332-
- Non-repeat inputs will be remembered as a string in short time to look for next file prefix match.
331+
- Repeat inputting same character will look for next file that prefixes with it. + `Shift` for reverse direction.
332+
- Non-repeat inputs will be remembered as a string in short time to look for next file prefix match. + `Shift` for reverse direction.
333333
- When upload is enabled, pasting(`Ctrl`/`Cmd` + `v`) image or text content will upload that content as a file.

README.zh-CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,6 @@ ghfs [选项]
318318
- ``, ``:使焦点在文件项之间移动
319319
- `Ctrl`/`Opt` + ``:把焦点移动到第一个文件项
320320
- `Ctrl`/`Opt` + ``:把焦点移动到最后一个文件项
321-
- 重复输入相同字符将查找下一个前缀匹配该字符的文件。
322-
- 输入不重复的字符,将在短时间内被记忆为字符串,用于查找下一个前缀匹配的文件。
321+
- 重复输入相同字符将查找下一个前缀匹配该字符的文件。+ `Shift`执行反向查找。
322+
- 输入不重复的字符,将在短时间内被记忆为字符串,用于查找下一个前缀匹配的文件。+ `Shift`执行反向查找。
323323
- 当已启用上传时,粘贴(`Ctrl`/`Cmd` + `v`)图像或文本会将此内容上传为文件。

src/tpl/defaultTheme/frontend/index.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
return;
244244
}
245245

246-
function getFocusableSibling(container, isPrev, startA) {
246+
function getFocusableSibling(container, isBackward, startA) {
247247
if (!container) {
248248
return
249249
}
@@ -255,7 +255,7 @@
255255
startLI = startLI.parentElement;
256256
}
257257
if (!startLI) {
258-
if (isPrev) {
258+
if (isBackward) {
259259
startLI = container.firstElementChild;
260260
} else {
261261
startLI = container.lastElementChild;
@@ -267,7 +267,7 @@
267267

268268
var siblingLI = startLI;
269269
do {
270-
if (isPrev) {
270+
if (isBackward) {
271271
siblingLI = siblingLI.previousElementSibling;
272272
if (!siblingLI) {
273273
siblingLI = container.lastElementChild;
@@ -303,7 +303,7 @@
303303
return a;
304304
}
305305

306-
function getMatchedFocusableSibling(container, isPrev, startA, buf) {
306+
function getMatchedFocusableSibling(container, isBackward, startA, buf) {
307307
var skipRound = buf.length === 1; // find next prefix
308308
var matchKeyA;
309309
var firstCheckA;
@@ -334,7 +334,7 @@
334334
if (buf.length <= textContent.length && textContent.substring(0, buf.length) === buf) {
335335
return a;
336336
}
337-
} while (a = getFocusableSibling(container, isPrev, a));
337+
} while (a = getFocusableSibling(container, isBackward, a));
338338
return matchKeyA;
339339
}
340340

@@ -376,7 +376,7 @@
376376
lookupTimer = setTimeout(clearLookupContext, 850);
377377
}
378378

379-
function lookup(key) {
379+
function lookup(key, isBackward) {
380380
key = key.toLowerCase();
381381

382382
var currentLookupStartA;
@@ -397,7 +397,7 @@
397397
lookupBuffer += key;
398398
}
399399
delayClearLookupContext();
400-
return getMatchedFocusableSibling(itemList, false, currentLookupStartA, lookupKey || lookupBuffer);
400+
return getMatchedFocusableSibling(itemList, isBackward, currentLookupStartA, lookupKey || lookupBuffer);
401401
}
402402

403403
var canArrowMove;
@@ -457,7 +457,7 @@
457457
}
458458
}
459459
if (!e.ctrlKey && (!e.altKey || IS_MAC_PLATFORM) && !e.metaKey && e.key.length === 1) {
460-
return lookup(e.key);
460+
return lookup(e.key, e.shiftKey);
461461
}
462462
} else if (e.keyCode) {
463463
if (canArrowMove(e)) {
@@ -489,7 +489,7 @@
489489
}
490490
}
491491
if (!e.ctrlKey && (!e.altKey || IS_MAC_PLATFORM) && !e.metaKey && e.keyCode >= 32 && e.keyCode <= 126) {
492-
return lookup(String.fromCharCode(e.keyCode));
492+
return lookup(String.fromCharCode(e.keyCode), e.shiftKey);
493493
}
494494
}
495495
}

0 commit comments

Comments
 (0)