dsh-ris-ide 1.7.1 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client-codemirror.js +18 -0
- package/lib/client.js +463 -46
- package/lib/index.js +464 -3
- package/package.json +1 -1
- package/test/client-viewer.test.mjs +292 -4
- package/test/host-search.test.mjs +125 -1
- package/test/host-tail.test.mjs +62 -0
package/lib/client.js
CHANGED
|
@@ -2333,6 +2333,10 @@ window.__ModuleLoader__.load({
|
|
|
2333
2333
|
setFindIndex(0)
|
|
2334
2334
|
}
|
|
2335
2335
|
setFindOpen(true)
|
|
2336
|
+
// `findOpen` may already be true (the bar is open, focus is in the log
|
|
2337
|
+
// body), so the focus effect below would not run again — put the caret
|
|
2338
|
+
// in the find field right here, like the CodeMirror panel does.
|
|
2339
|
+
if (findInputRef.current !== null) findInputRef.current.focus()
|
|
2336
2340
|
return
|
|
2337
2341
|
}
|
|
2338
2342
|
if (event.key === 'Escape' && findOpen) {
|
|
@@ -3687,6 +3691,28 @@ window.__ModuleLoader__.load({
|
|
|
3687
3691
|
return out
|
|
3688
3692
|
}
|
|
3689
3693
|
|
|
3694
|
+
/**
|
|
3695
|
+
* Whether `child` is `parent` itself or lives below it.
|
|
3696
|
+
*
|
|
3697
|
+
* The file tree can be re-rooted into a subfolder (context menu 进入 / a folder
|
|
3698
|
+
* search hit), so `activeRoot` is NOT always the workspace root: locating a
|
|
3699
|
+
* file then has to ask whether the file is reachable from where the tree is
|
|
3700
|
+
* currently rooted at all.
|
|
3701
|
+
* @param {string} parent - absolute directory (trailing slashes ignored).
|
|
3702
|
+
* @param {string} child - absolute path.
|
|
3703
|
+
* @returns {boolean} true when `child` is `parent` or inside it.
|
|
3704
|
+
*/
|
|
3705
|
+
function pathWithin(parent, child) {
|
|
3706
|
+
var raw = String(parent === undefined || parent === null ? '' : parent).replace(/\\/g, '/')
|
|
3707
|
+
var value = String(child === undefined || child === null ? '' : child).replace(/\\/g, '/')
|
|
3708
|
+
var base = raw.replace(/\/+$/, '')
|
|
3709
|
+
// The filesystem root is the one parent whose trailing slash IS its name.
|
|
3710
|
+
if (base === '' && raw !== '') base = '/'
|
|
3711
|
+
if (base === '' || value === '') return false
|
|
3712
|
+
if (base === '/') return value.charAt(0) === '/'
|
|
3713
|
+
return value === base || value.indexOf(base + '/') === 0
|
|
3714
|
+
}
|
|
3715
|
+
|
|
3690
3716
|
/**
|
|
3691
3717
|
* The visible entry of ONE level that contains `filePath` (its own path, or a
|
|
3692
3718
|
* prefix of it). Compaction means a single entry can stand for a whole raw
|
|
@@ -3916,11 +3942,31 @@ window.__ModuleLoader__.load({
|
|
|
3916
3942
|
* (`cn.com.ris.cloud.model`) is expanded as the ONE row it is instead of
|
|
3917
3943
|
* walking absolute-path ancestors that no row represents — the old walk left
|
|
3918
3944
|
* the branch empty. Depth is capped and a visited set stops on any repeat.
|
|
3945
|
+
*
|
|
3946
|
+
* Two things used to make the button「sometimes do nothing」:
|
|
3947
|
+
* - the walk read its per-level key from the loop variable inside the
|
|
3948
|
+
* `setExpanded` updater, and React runs that updater LATER — by then the
|
|
3949
|
+
* variable held a deeper path, so the top ancestors never expanded and
|
|
3950
|
+
* the row never existed (the same trap `fetchLevel` documents). The chain
|
|
3951
|
+
* is collected in an array and committed in ONE update instead.
|
|
3952
|
+
* - a tree re-rooted into a subfolder (进入 / a folder search hit) walked
|
|
3953
|
+
* from that subfolder only, so a file outside it was unreachable and the
|
|
3954
|
+
* click silently did nothing. The walk now falls back to the workspace
|
|
3955
|
+
* root, which also re-roots the tree there.
|
|
3919
3956
|
* @param {string} target - file path (relative to `cwd` or absolute).
|
|
3920
3957
|
*/
|
|
3921
3958
|
async function locate(target) {
|
|
3922
3959
|
var filePath = absolutePath(cwd, target)
|
|
3923
|
-
var
|
|
3960
|
+
var workspaceRoot = absolutePath(cwd, rootPath)
|
|
3961
|
+
var startRoot = absolutePath(cwd, activeRoot)
|
|
3962
|
+
// The tree only walks from its current root; a file outside it is only
|
|
3963
|
+
// reachable from the workspace root, so the tree follows the locate.
|
|
3964
|
+
if (!pathWithin(startRoot, filePath) && pathWithin(workspaceRoot, filePath)) {
|
|
3965
|
+
startRoot = workspaceRoot
|
|
3966
|
+
setRootTrail([])
|
|
3967
|
+
}
|
|
3968
|
+
var chain = []
|
|
3969
|
+
var current = startRoot
|
|
3924
3970
|
var visited = {}
|
|
3925
3971
|
for (var guard = 0; guard < 64; guard += 1) {
|
|
3926
3972
|
if (visited[current] === true) break
|
|
@@ -3942,9 +3988,22 @@ window.__ModuleLoader__.load({
|
|
|
3942
3988
|
if (levels[descend] === undefined) {
|
|
3943
3989
|
try { await fetchLevel(descend) } catch (problem) { /* best effort */ }
|
|
3944
3990
|
}
|
|
3945
|
-
|
|
3991
|
+
chain.push(descend)
|
|
3946
3992
|
current = descend
|
|
3947
3993
|
}
|
|
3994
|
+
if (chain.length > 0) {
|
|
3995
|
+
// `chain` is frozen once the walk is done, and the updater reads it (never
|
|
3996
|
+
// the loop variable) — every ancestor of the file is open in one commit.
|
|
3997
|
+
setExpanded(function (prev) {
|
|
3998
|
+
var state = Object.assign({}, prev)
|
|
3999
|
+
for (var index = 0; index < chain.length; index += 1) state[chain[index]] = true
|
|
4000
|
+
return state
|
|
4001
|
+
})
|
|
4002
|
+
}
|
|
4003
|
+
// The located file becomes the tree's selection: a folder that happened to
|
|
4004
|
+
// be selected before (a right click, a multi-selection) must not keep the
|
|
4005
|
+
// strong tint next to the file the editor is now showing.
|
|
4006
|
+
selectOne(filePath)
|
|
3948
4007
|
props.onOpen(filePath)
|
|
3949
4008
|
revealRow(filePath)
|
|
3950
4009
|
}
|
|
@@ -4120,6 +4179,12 @@ window.__ModuleLoader__.load({
|
|
|
4120
4179
|
var [batchConflict, setBatchConflict] = useState(null)
|
|
4121
4180
|
/** Pending delete confirmation: the entry to remove. */
|
|
4122
4181
|
var [pendingDelete, setPendingDelete] = useState(null)
|
|
4182
|
+
/**
|
|
4183
|
+
* A drag that landed on a folder: the move waits for 确认 (`{paths, dir}`).
|
|
4184
|
+
* Dropping used to relocate files on release, so a slip of the mouse (or a
|
|
4185
|
+
* drop meant for the editor) moved them with no way to notice in time.
|
|
4186
|
+
*/
|
|
4187
|
+
var [pendingMove, setPendingMove] = useState(null)
|
|
4123
4188
|
/** Clipboard for copy/cut: `{mode, items:[{path,isDir,name}]}`. */
|
|
4124
4189
|
var [clipboard, setClipboard] = useState(null)
|
|
4125
4190
|
var [selectedPath, setSelectedPath] = useState(null)
|
|
@@ -4135,6 +4200,7 @@ window.__ModuleLoader__.load({
|
|
|
4135
4200
|
var promptInputRef = useRef(null)
|
|
4136
4201
|
/** The delete dialog's 取消 button: focus target so Esc/Enter never fall to BODY. */
|
|
4137
4202
|
var confirmCancelRef = useRef(null)
|
|
4203
|
+
var moveCancelRef = useRef(null)
|
|
4138
4204
|
/** Auto-retry bookkeeping for an unreachable/reloading host. */
|
|
4139
4205
|
var treeRetryRef = useRef({ attempt: 0, timer: null })
|
|
4140
4206
|
var levelsRef = useRef(levels)
|
|
@@ -4409,6 +4475,24 @@ window.__ModuleLoader__.load({
|
|
|
4409
4475
|
}
|
|
4410
4476
|
}, [pendingDelete])
|
|
4411
4477
|
|
|
4478
|
+
// Same contract for the move confirmation: 取消 owns focus, Esc cancels,
|
|
4479
|
+
// and the tree gets the keyboard back when it closes.
|
|
4480
|
+
useEffect(function () {
|
|
4481
|
+
if (pendingMove === null) return undefined
|
|
4482
|
+
var cancel = moveCancelRef.current
|
|
4483
|
+
if (cancel !== null && cancel !== undefined && typeof cancel.focus === 'function') cancel.focus()
|
|
4484
|
+
function onKey(event) {
|
|
4485
|
+
if (event.key !== 'Escape') return
|
|
4486
|
+
event.preventDefault()
|
|
4487
|
+
setPendingMove(null)
|
|
4488
|
+
}
|
|
4489
|
+
document.addEventListener('keydown', onKey, true)
|
|
4490
|
+
return function () {
|
|
4491
|
+
document.removeEventListener('keydown', onKey, true)
|
|
4492
|
+
focusTreeRoot()
|
|
4493
|
+
}
|
|
4494
|
+
}, [pendingMove])
|
|
4495
|
+
|
|
4412
4496
|
// The selection follows the disk: a path that vanished (deleted, moved away,
|
|
4413
4497
|
// watcher reload, folded folder) must leave the batch, or the status bar and
|
|
4414
4498
|
// the delete dialog count ghosts (PM review P1-3, found live: 「删除 3 项?」
|
|
@@ -5297,13 +5381,44 @@ window.__ModuleLoader__.load({
|
|
|
5297
5381
|
}
|
|
5298
5382
|
}
|
|
5299
5383
|
/**
|
|
5300
|
-
*
|
|
5301
|
-
*
|
|
5384
|
+
* Paths a drop on `dirPath` would actually move: skips the folder itself,
|
|
5385
|
+
* rows already in it, and a folder dragged into its own subtree.
|
|
5386
|
+
* @param {string[]} paths - dragged absolute paths.
|
|
5387
|
+
* @param {string} dirPath - drop directory.
|
|
5388
|
+
* @returns {string[]} the paths worth confirming.
|
|
5389
|
+
*/
|
|
5390
|
+
function movablePaths(paths, dirPath) {
|
|
5391
|
+
var trimmedDir = dirPath.replace(/[\\/]+$/, '')
|
|
5392
|
+
var movable = []
|
|
5393
|
+
for (var index = 0; index < paths.length; index += 1) {
|
|
5394
|
+
var from = paths[index]
|
|
5395
|
+
if (typeof from !== 'string' || from === '') continue
|
|
5396
|
+
if (from === trimmedDir || parentOf(from) === trimmedDir) continue
|
|
5397
|
+
var entry = findEntry(from)
|
|
5398
|
+
if (entry !== undefined && entry !== null && entry.isDir === true && trimmedDir.indexOf(from + '/') === 0) continue
|
|
5399
|
+
movable.push(from)
|
|
5400
|
+
}
|
|
5401
|
+
return movable
|
|
5402
|
+
}
|
|
5403
|
+
|
|
5404
|
+
/** A drop inside the tree: ask first, announce exactly what moves where. */
|
|
5405
|
+
function requestMove(paths, dirPath) {
|
|
5406
|
+
var movable = movablePaths(paths, dirPath)
|
|
5407
|
+
setDropTarget(null)
|
|
5408
|
+
if (movable.length === 0) return
|
|
5409
|
+
setSelectedPaths(movable)
|
|
5410
|
+
setSelectedPath(movable[movable.length - 1])
|
|
5411
|
+
setPendingMove({ paths: movable, dir: dirPath })
|
|
5412
|
+
}
|
|
5413
|
+
|
|
5414
|
+
/**
|
|
5415
|
+
* Move rows (one confirmed drag of a row, or of the whole multi-selection)
|
|
5416
|
+
* into `dirPath`.
|
|
5302
5417
|
*
|
|
5303
|
-
* Every collision becomes a `… 副本` name — a
|
|
5304
|
-
* dialog — and the batch is reported in one toast. Rows
|
|
5305
|
-
* target (or a directory dropped into itself) are
|
|
5306
|
-
* entry (Ctrl+Z) puts everything back.
|
|
5418
|
+
* Every collision becomes a `… 副本` name — even a confirmed move must not
|
|
5419
|
+
* stop half way for a dialog — and the batch is reported in one toast. Rows
|
|
5420
|
+
* already inside the target (or a directory dropped into itself) are
|
|
5421
|
+
* skipped. One compound undo entry (Ctrl+Z) puts everything back.
|
|
5307
5422
|
* @param {string[]} paths - absolute source paths, in drop order.
|
|
5308
5423
|
* @param {string} dirPath - absolute destination directory.
|
|
5309
5424
|
*/
|
|
@@ -5405,7 +5520,7 @@ window.__ModuleLoader__.load({
|
|
|
5405
5520
|
|| active === root
|
|
5406
5521
|
)
|
|
5407
5522
|
if (!inside) return
|
|
5408
|
-
if (prompt !== null || pendingDelete !== null) return
|
|
5523
|
+
if (prompt !== null || pendingDelete !== null || pendingMove !== null) return
|
|
5409
5524
|
if (event.key === 'Escape' && selectedPaths.length > 1) {
|
|
5410
5525
|
// Esc drops the batch but keeps the primary row: batch ops are silent,
|
|
5411
5526
|
// so there must be a one-key way out of a mis-clicked selection.
|
|
@@ -5570,12 +5685,18 @@ window.__ModuleLoader__.load({
|
|
|
5570
5685
|
seen[entry.path] = true
|
|
5571
5686
|
var open = expanded[entry.path] === true
|
|
5572
5687
|
var isActive = props.activePath === entry.path
|
|
5573
|
-
var isRevealed = reveal !== null && reveal.path === entry.path
|
|
5574
5688
|
var isSelected = selectedPath === entry.path
|
|
5575
5689
|
&& (entry.isDir === true || !Array.isArray(props.openFiles) || props.openFiles.indexOf(entry.path) !== -1)
|
|
5576
5690
|
// Extra rows of a multi-selection: highlighted but NOT the primary row
|
|
5577
5691
|
// (menus, rename/delete and the paste target keep acting on `selectedPath`).
|
|
5578
5692
|
var isMulti = selectedPaths.length > 1 && selectedPaths.indexOf(entry.path) !== -1 && !isSelected
|
|
5693
|
+
// The STRONG row tint means one thing only: this is the file the editor is
|
|
5694
|
+
// showing (or the directory a rename/delete/paste is aimed at). A locate
|
|
5695
|
+
// used to paint the located row and keep it lit until the next locate, so
|
|
5696
|
+
// old files stayed highlighted after switching tabs; a file row that is
|
|
5697
|
+
// merely selected (right click, Ctrl+click) now wears the softer multi
|
|
5698
|
+
// tint, keeping the tree's current-file highlight in step with the tabs.
|
|
5699
|
+
var isCurrent = isActive || (isSelected && entry.isDir === true)
|
|
5579
5700
|
// Dropping ON a file means "into the folder that file lives in" — a row
|
|
5580
5701
|
// is always a drop target; only the expand/collapse toggle is dir-only.
|
|
5581
5702
|
var dropDir = entry.isDir === true ? entry.path : parentOf(entry.path)
|
|
@@ -5583,14 +5704,14 @@ window.__ModuleLoader__.load({
|
|
|
5583
5704
|
out.push(h('div', {
|
|
5584
5705
|
key: entry.path,
|
|
5585
5706
|
style: Object.assign({},
|
|
5586
|
-
|
|
5707
|
+
isCurrent ? S.treeRowOn : (isMulti || isSelected ? S.treeRowMulti : S.treeRow),
|
|
5587
5708
|
{
|
|
5588
5709
|
paddingLeft: indent,
|
|
5589
5710
|
boxShadow: isDropTarget ? 'inset 0 0 0 1px #d29922' : undefined,
|
|
5590
5711
|
}),
|
|
5591
5712
|
title: entry.path + (entry.isDir === true ? '(点击:把这个目录当作文件树根 / 三角:展开折叠)' : '') + '(Ctrl+点击 多选 / 右键:新建/粘贴/复制/剪切/删除/刷新)',
|
|
5592
5713
|
'data-tree-path': entry.path,
|
|
5593
|
-
'data-tree-
|
|
5714
|
+
'data-tree-current': isCurrent ? '1' : undefined,
|
|
5594
5715
|
'data-tree-selected': isSelected ? '1' : undefined,
|
|
5595
5716
|
'data-tree-multi': isMulti ? '1' : undefined,
|
|
5596
5717
|
'data-tree-drop': isDropTarget ? '1' : undefined,
|
|
@@ -5630,8 +5751,8 @@ window.__ModuleLoader__.load({
|
|
|
5630
5751
|
var paths = dragPaths(event.dataTransfer)
|
|
5631
5752
|
if (paths.length === 0 && selectedPath !== null) paths = [selectedPath]
|
|
5632
5753
|
paths = paths.filter(function (item) { return item !== entry.path })
|
|
5633
|
-
if (paths.length > 0)
|
|
5634
|
-
setDropTarget(null)
|
|
5754
|
+
if (paths.length > 0) requestMove(paths, dropDir)
|
|
5755
|
+
else setDropTarget(null)
|
|
5635
5756
|
},
|
|
5636
5757
|
onClick: function (event) {
|
|
5637
5758
|
var additive = event.ctrlKey === true || event.metaKey === true
|
|
@@ -5995,10 +6116,46 @@ window.__ModuleLoader__.load({
|
|
|
5995
6116
|
]
|
|
5996
6117
|
}
|
|
5997
6118
|
|
|
6119
|
+
/** The move confirmation: what moves where, 取消 by default. */
|
|
6120
|
+
function renderTreeMoveConfirm() {
|
|
6121
|
+
if (pendingMove === null) return null
|
|
6122
|
+
var paths = pendingMove.paths
|
|
6123
|
+
var dir = pendingMove.dir
|
|
6124
|
+
var first = findEntry(paths[0])
|
|
6125
|
+
var isDir = first !== undefined && first !== null && first.isDir === true
|
|
6126
|
+
var label = paths.length > 1
|
|
6127
|
+
? '移动 ' + paths.length + ' 项?'
|
|
6128
|
+
: (isDir ? '移动这个文件夹?' : '移动这个文件?')
|
|
6129
|
+
var detail = paths.map(function (item) { return fileBaseName(item) + (findEntry(item) !== undefined && findEntry(item) !== null && findEntry(item).isDir === true ? '/' : '') }).join('、')
|
|
6130
|
+
var anchor = dialogAnchor(360, 176)
|
|
6131
|
+
return [
|
|
6132
|
+
h('div', { key: 'move-mask', style: { position: 'fixed', inset: 0, zIndex: 949, background: 'transparent' }, 'data-tree-move-mask': '1', onClick: function () { setPendingMove(null) } }),
|
|
6133
|
+
h('div', {
|
|
6134
|
+
key: 'move-card',
|
|
6135
|
+
style: { position: 'fixed', left: anchor.left, top: anchor.top, zIndex: 950, width: 360, maxWidth: '92vw', background: 'Canvas', color: 'inherit', border: '1px solid color-mix(in srgb, currentColor 25%, transparent)', borderRadius: 6, boxShadow: '0 18px 48px rgba(0,0,0,0.4)', padding: 10, display: 'flex', flexDirection: 'column', gap: 8, fontFamily: 'system-ui, sans-serif', fontSize: 12 },
|
|
6136
|
+
'data-tree-move-confirm': '1',
|
|
6137
|
+
},
|
|
6138
|
+
h('div', { style: { fontWeight: 600 } }, label),
|
|
6139
|
+
h('div', { style: { opacity: 0.75, wordBreak: 'break-all' } }, detail),
|
|
6140
|
+
h('div', { style: { opacity: 0.6, wordBreak: 'break-all' } }, '移动到:' + dir),
|
|
6141
|
+
h('div', { style: { opacity: 0.6 } }, '移动后可按 Ctrl+Z 撤销'),
|
|
6142
|
+
h('div', { style: { display: 'flex', justifyContent: 'flex-end', gap: 6 } },
|
|
6143
|
+
h('button', { type: 'button', style: S.buttonOff, ref: moveCancelRef, 'data-tree-move-cancel': '1', onClick: function () { setPendingMove(null) } }, '取消'),
|
|
6144
|
+
h('button', {
|
|
6145
|
+
type: 'button', style: S.button, 'data-tree-move-ok': '1',
|
|
6146
|
+
onClick: function () {
|
|
6147
|
+
var pending = pendingMove
|
|
6148
|
+
setPendingMove(null)
|
|
6149
|
+
if (pending !== null) void moveEntriesInto(pending.paths, pending.dir)
|
|
6150
|
+
},
|
|
6151
|
+
}, '移动'))),
|
|
6152
|
+
]
|
|
6153
|
+
}
|
|
6154
|
+
|
|
5998
6155
|
// Freeze the anchor once per dialog opening and release it when the last
|
|
5999
6156
|
// dialog closes. Assigning during render is safe here: it only pins the
|
|
6000
6157
|
// point the JSX below already reads; it never drives rendering.
|
|
6001
|
-
var anyDialogOpen = prompt !== null || pendingDelete !== null || batchConflict !== null
|
|
6158
|
+
var anyDialogOpen = prompt !== null || pendingDelete !== null || batchConflict !== null || pendingMove !== null
|
|
6002
6159
|
if (anyDialogOpen === false) dialogPointRef.current = null
|
|
6003
6160
|
else if (dialogPointRef.current === null && pointerRef.current !== null) dialogPointRef.current = pointerRef.current
|
|
6004
6161
|
|
|
@@ -6044,7 +6201,7 @@ window.__ModuleLoader__.load({
|
|
|
6044
6201
|
var paths = dragPaths(event.dataTransfer)
|
|
6045
6202
|
if (paths.length === 0 && selectedPath !== null) paths = [selectedPath]
|
|
6046
6203
|
paths = paths.filter(function (item) { return parentOf(item) !== rootDir })
|
|
6047
|
-
if (paths.length > 0)
|
|
6204
|
+
if (paths.length > 0) requestMove(paths, rootDir)
|
|
6048
6205
|
},
|
|
6049
6206
|
}, rootTrail.length > 0
|
|
6050
6207
|
? h('div', {
|
|
@@ -6058,6 +6215,7 @@ window.__ModuleLoader__.load({
|
|
|
6058
6215
|
renderTreeMenu(),
|
|
6059
6216
|
renderTreePrompt(),
|
|
6060
6217
|
renderTreeConfirm(),
|
|
6218
|
+
renderTreeMoveConfirm(),
|
|
6061
6219
|
renderBatchConflict())
|
|
6062
6220
|
}
|
|
6063
6221
|
|
|
@@ -6077,6 +6235,7 @@ window.__ModuleLoader__.load({
|
|
|
6077
6235
|
var lines = text.split('\n')
|
|
6078
6236
|
var areaRef = useRef(null)
|
|
6079
6237
|
var [findOpen, setFindOpen] = useState(false)
|
|
6238
|
+
var findInputRef = useRef(null)
|
|
6080
6239
|
var [findText, setFindText] = useState('')
|
|
6081
6240
|
var [replaceText, setReplaceText] = useState('')
|
|
6082
6241
|
var [findNote, setFindNote] = useState(undefined)
|
|
@@ -6147,6 +6306,13 @@ window.__ModuleLoader__.load({
|
|
|
6147
6306
|
}
|
|
6148
6307
|
}
|
|
6149
6308
|
setFindOpen(true)
|
|
6309
|
+
// The bar's input is `autoFocus` only on the render that MOUNTS it: with
|
|
6310
|
+
// the bar already open a second Ctrl+F must still move the caret there.
|
|
6311
|
+
var findInput = findInputRef.current
|
|
6312
|
+
if (findInput !== null && findInput !== undefined) {
|
|
6313
|
+
findInput.focus()
|
|
6314
|
+
if (typeof findInput.select === 'function') findInput.select()
|
|
6315
|
+
}
|
|
6150
6316
|
return
|
|
6151
6317
|
}
|
|
6152
6318
|
if ((event.ctrlKey || event.metaKey) && (event.key === 's' || event.key === 'S')) {
|
|
@@ -6171,7 +6337,7 @@ window.__ModuleLoader__.load({
|
|
|
6171
6337
|
}
|
|
6172
6338
|
var findBar = findOpen ? h('div', { style: S.findBar, 'data-editor-find': '1' },
|
|
6173
6339
|
h('input', {
|
|
6174
|
-
style: S.findInput, value: findText, placeholder: '在文件中查找…', autoFocus: true,
|
|
6340
|
+
ref: findInputRef, style: S.findInput, value: findText, placeholder: '在文件中查找…', autoFocus: true,
|
|
6175
6341
|
'data-action': 'find-input',
|
|
6176
6342
|
onChange: function (event) { setFindText(event.target.value); setFindNote(undefined) },
|
|
6177
6343
|
onKeyDown: function (event) {
|
|
@@ -6425,7 +6591,11 @@ window.__ModuleLoader__.load({
|
|
|
6425
6591
|
* using the same `color-mix` / inherited-colour palette as the title bars, so
|
|
6426
6592
|
* light and dark themes both follow the page instead of hard-coding colours.
|
|
6427
6593
|
*/
|
|
6428
|
-
|
|
6594
|
+
// `z-index:20` (baseTheme says 300): the panel only has to sit above the editor's
|
|
6595
|
+
// own content layers, and 300 made it cover the workspace-search dropdown — that
|
|
6596
|
+
// dropdown is anchored in the pane's header row (`editorPaneHead`, z-index 30) and
|
|
6597
|
+
// opens right over the editor's top edge. The header row therefore has to win.
|
|
6598
|
+
var SEARCH_PANEL_CSS = '[data-workbench="ris-ide"] .cm-panels{background:color-mix(in srgb, Canvas 96%, transparent) !important;color:inherit !important;border:0 !important;z-index:20 !important}'
|
|
6429
6599
|
+ '[data-workbench="ris-ide"] .cm-panels-top{border-bottom:1px solid color-mix(in srgb, currentColor 12%, transparent) !important}'
|
|
6430
6600
|
+ '[data-workbench="ris-ide"] .cm-panels-bottom{border-top:1px solid color-mix(in srgb, currentColor 12%, transparent) !important}'
|
|
6431
6601
|
// The panel is the IDE's own (`ideFindPanel` in the editor chunk): two rows,
|
|
@@ -8785,7 +8955,7 @@ var [ui, setUi] = useState(function () {
|
|
|
8785
8955
|
return function () { window.removeEventListener('mousedown', onDown); window.removeEventListener('keydown', onKey) }
|
|
8786
8956
|
}, [tabMenu])
|
|
8787
8957
|
|
|
8788
|
-
/** Toolbar search: debounce, then
|
|
8958
|
+
/** Toolbar search: debounce, then stream matches page by page from the host route. */
|
|
8789
8959
|
useEffect(function () {
|
|
8790
8960
|
var text = treeQuery.trim()
|
|
8791
8961
|
if (text === '') { setSearchHits(null); setSearchBusy(false); return undefined }
|
|
@@ -8796,27 +8966,43 @@ var [ui, setUi] = useState(function () {
|
|
|
8796
8966
|
return undefined
|
|
8797
8967
|
}
|
|
8798
8968
|
var cancelled = false
|
|
8969
|
+
var controller = typeof AbortController === 'function' ? new AbortController() : null
|
|
8799
8970
|
setSearchBusy(true)
|
|
8800
8971
|
var timer = setTimeout(function () {
|
|
8801
|
-
|
|
8972
|
+
var matches = []
|
|
8973
|
+
fsSearchStream(scopeRef.current, text, {
|
|
8974
|
+
onPage: function (page) {
|
|
8975
|
+
if (cancelled || Array.isArray(page) !== true) return
|
|
8976
|
+
for (var index = 0; index < page.length; index += 1) {
|
|
8977
|
+
if (typeof page[index] === 'string') matches.push(page[index])
|
|
8978
|
+
}
|
|
8979
|
+
// Paint the first page immediately: later roots append while the user reads.
|
|
8980
|
+
if (matches.length > 0) setSearchHits({ matches: matches.slice(), dirs: {} })
|
|
8981
|
+
},
|
|
8982
|
+
}, controller === null ? undefined : controller.signal).then(function () {
|
|
8802
8983
|
if (cancelled) return
|
|
8803
|
-
var payload = searchHitPayload(
|
|
8984
|
+
var payload = searchHitPayload({ matches: matches.slice(), dirs: {} }, cwd)
|
|
8804
8985
|
rememberSearchEntry(searchCacheRef.current, 'name:' + text, payload)
|
|
8805
8986
|
setSearchHits(payload)
|
|
8806
8987
|
setSearchBusy(false)
|
|
8807
8988
|
}).catch(function (problem) {
|
|
8808
|
-
if (cancelled) return
|
|
8989
|
+
if (cancelled || isAbortError(problem)) return
|
|
8809
8990
|
setSearchHits({ error: messageOf(problem) || '未知错误' })
|
|
8810
8991
|
setSearchBusy(false)
|
|
8811
8992
|
})
|
|
8812
8993
|
}, 250)
|
|
8813
|
-
return function () {
|
|
8994
|
+
return function () {
|
|
8995
|
+
cancelled = true
|
|
8996
|
+
clearTimeout(timer)
|
|
8997
|
+
if (controller !== null) controller.abort()
|
|
8998
|
+
}
|
|
8814
8999
|
}, [treeQuery, cwd])
|
|
8815
9000
|
|
|
8816
9001
|
/**
|
|
8817
9002
|
* Content search for the same query: slower than the name search (one
|
|
8818
9003
|
* `git grep -n` per call, no index — a deliberate product promise), so it
|
|
8819
|
-
* runs on its own slightly longer debounce
|
|
9004
|
+
* runs on its own slightly longer debounce, never blocks the file list, and
|
|
9005
|
+
* streams its hits page by page like the name search.
|
|
8820
9006
|
*/
|
|
8821
9007
|
useEffect(function () {
|
|
8822
9008
|
var text = treeQuery.trim()
|
|
@@ -8828,20 +9014,33 @@ var [ui, setUi] = useState(function () {
|
|
|
8828
9014
|
return undefined
|
|
8829
9015
|
}
|
|
8830
9016
|
var cancelled = false
|
|
9017
|
+
var controller = typeof AbortController === 'function' ? new AbortController() : null
|
|
8831
9018
|
setContentBusy(true)
|
|
8832
9019
|
var timer = setTimeout(function () {
|
|
8833
|
-
|
|
9020
|
+
var hits = []
|
|
9021
|
+
fsSearchContentStream(scopeRef.current, text, {
|
|
9022
|
+
onPage: function (page) {
|
|
9023
|
+
if (cancelled || Array.isArray(page) !== true) return
|
|
9024
|
+
for (var index = 0; index < page.length; index += 1) hits.push(page[index])
|
|
9025
|
+
if (hits.length > 0) setContentHits(hits.slice())
|
|
9026
|
+
},
|
|
9027
|
+
}, controller === null ? undefined : controller.signal).then(function () {
|
|
8834
9028
|
if (cancelled) return
|
|
8835
|
-
|
|
8836
|
-
|
|
9029
|
+
var payload = hits.slice()
|
|
9030
|
+
rememberSearchEntry(searchCacheRef.current, 'content:' + text, payload)
|
|
9031
|
+
setContentHits(payload)
|
|
8837
9032
|
setContentBusy(false)
|
|
8838
|
-
}).catch(function () {
|
|
8839
|
-
if (cancelled) return
|
|
9033
|
+
}).catch(function (problem) {
|
|
9034
|
+
if (cancelled || isAbortError(problem)) return
|
|
8840
9035
|
setContentHits([])
|
|
8841
9036
|
setContentBusy(false)
|
|
8842
9037
|
})
|
|
8843
9038
|
}, 450)
|
|
8844
|
-
return function () {
|
|
9039
|
+
return function () {
|
|
9040
|
+
cancelled = true
|
|
9041
|
+
clearTimeout(timer)
|
|
9042
|
+
if (controller !== null) controller.abort()
|
|
9043
|
+
}
|
|
8845
9044
|
}, [treeQuery, cwd])
|
|
8846
9045
|
|
|
8847
9046
|
/**
|
|
@@ -10114,6 +10313,38 @@ var [ui, setUi] = useState(function () {
|
|
|
10114
10313
|
return function () { window.removeEventListener('keydown', onKey) }
|
|
10115
10314
|
}, [visible])
|
|
10116
10315
|
|
|
10316
|
+
// Ctrl/Cmd+F is the editor's find chord and, in the standalone IDE window, it
|
|
10317
|
+
// must never fall through to the browser's own find bar. CodeMirror handles it
|
|
10318
|
+
// while the caret sits in the document, and the panel handles keys pressed
|
|
10319
|
+
// inside itself (both mark the event handled — see `defaultPrevented`); this
|
|
10320
|
+
// listener is the last line for every other focus: the tabs bar, the tree, or
|
|
10321
|
+
// the workspace search box. There it opens the open file's find panel, and the
|
|
10322
|
+
// workspace search box when the open file has no editor (images, "no file").
|
|
10323
|
+
useEffect(function () {
|
|
10324
|
+
if (typeof window === 'undefined' || typeof window.addEventListener !== 'function') return undefined
|
|
10325
|
+
if (visible === false) return undefined
|
|
10326
|
+
function onFindKey(event) {
|
|
10327
|
+
if (event.defaultPrevented === true) return
|
|
10328
|
+
if (event.ctrlKey !== true && event.metaKey !== true) return
|
|
10329
|
+
if (event.altKey === true || event.shiftKey === true) return
|
|
10330
|
+
var key = String(event.key === undefined || event.key === null ? '' : event.key).toLowerCase()
|
|
10331
|
+
if (key !== 'f') return
|
|
10332
|
+
if (!ownsKeyTarget(event.target)) return
|
|
10333
|
+
event.preventDefault()
|
|
10334
|
+
event.stopPropagation()
|
|
10335
|
+
var controls = typeof openFile === 'string' ? viewerControlsRef.current[openFile] : undefined
|
|
10336
|
+
if (controls !== undefined && controls !== null && typeof controls.find === 'function') {
|
|
10337
|
+
controls.find()
|
|
10338
|
+
return
|
|
10339
|
+
}
|
|
10340
|
+
if (searchInputRef.current === null) return
|
|
10341
|
+
searchFocusPendingRef.current = true
|
|
10342
|
+
setSearchFocusNonce(function (value) { return value + 1 })
|
|
10343
|
+
}
|
|
10344
|
+
window.addEventListener('keydown', onFindKey)
|
|
10345
|
+
return function () { window.removeEventListener('keydown', onFindKey) }
|
|
10346
|
+
}, [visible, openFile])
|
|
10347
|
+
|
|
10117
10348
|
/** Bottom-right help: every shortcut group plus a short how-to. */
|
|
10118
10349
|
function renderHelpPanel() {
|
|
10119
10350
|
return h('div', {
|
|
@@ -11872,6 +12103,12 @@ var [ui, setUi] = useState(function () {
|
|
|
11872
12103
|
return parsed
|
|
11873
12104
|
}
|
|
11874
12105
|
|
|
12106
|
+
/**
|
|
12107
|
+
* Bytes per upload chunk for a save too large for one request. The host stages
|
|
12108
|
+
* the chunks in a sibling temp file and renames it on the last one, so a big
|
|
12109
|
+
* document is saved without a body-size ceiling (and never half-written).
|
|
12110
|
+
*/
|
|
12111
|
+
var SAVE_CHUNK_BYTES = 512 * 1024
|
|
11875
12112
|
/**
|
|
11876
12113
|
* Write a text file back.
|
|
11877
12114
|
*
|
|
@@ -11885,23 +12122,50 @@ var [ui, setUi] = useState(function () {
|
|
|
11885
12122
|
* @returns {Promise<{mtimeMs?: number}>} the fresh baseline.
|
|
11886
12123
|
*/
|
|
11887
12124
|
async function fsWrite(scope, path, content) {
|
|
11888
|
-
var
|
|
11889
|
-
|
|
11890
|
-
|
|
11891
|
-
|
|
11892
|
-
|
|
11893
|
-
|
|
11894
|
-
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
|
|
11900
|
-
|
|
11901
|
-
|
|
11902
|
-
|
|
12125
|
+
var payload = {
|
|
12126
|
+
sessionId: scope.sessionId,
|
|
12127
|
+
...(typeof scope.cwd === 'string' && scope.cwd !== '' ? { cwd: scope.cwd } : {}),
|
|
12128
|
+
path: path,
|
|
12129
|
+
}
|
|
12130
|
+
/** POST one body and return the host's answer, or throw its message. */
|
|
12131
|
+
async function postWrite(body) {
|
|
12132
|
+
var url = routeUrl('dsh-ris-ide/fs/write')
|
|
12133
|
+
var response = await fetch(url.href, {
|
|
12134
|
+
method: 'POST',
|
|
12135
|
+
headers: { 'content-type': 'application/json' },
|
|
12136
|
+
body: JSON.stringify(body),
|
|
12137
|
+
})
|
|
12138
|
+
var parsed = await response.json().catch(function () { return null })
|
|
12139
|
+
if (!response.ok || parsed === null || parsed.ok !== true) {
|
|
12140
|
+
if (parsed !== null && parsed.message !== undefined) throw new Error(parsed.message)
|
|
12141
|
+
throw new Error('HTTP ' + response.status)
|
|
12142
|
+
}
|
|
12143
|
+
return parsed
|
|
12144
|
+
}
|
|
12145
|
+
// A save is chunked only when it would be a big body: a normal file must
|
|
12146
|
+
// stay ONE request (the host writes the whole document and answers once).
|
|
12147
|
+
var bytes = typeof TextEncoder === 'function' ? new TextEncoder().encode(content) : null
|
|
12148
|
+
if (bytes === null || bytes.length <= SAVE_CHUNK_BYTES) {
|
|
12149
|
+
var single = await postWrite(Object.assign({}, payload, { content: content }))
|
|
12150
|
+
return { mtimeMs: single.mtimeMs }
|
|
12151
|
+
}
|
|
12152
|
+
// Chunked save: utf8-safe slices, byte offsets, staged rename on the host.
|
|
12153
|
+
var decoder = typeof TextDecoder === 'function' ? new TextDecoder() : null
|
|
12154
|
+
var offset = 0
|
|
12155
|
+
var answer = null
|
|
12156
|
+
while (offset < bytes.length) {
|
|
12157
|
+
var end = Math.min(offset + SAVE_CHUNK_BYTES, bytes.length)
|
|
12158
|
+
// Never cut a multi-byte code point: back off to its leading byte.
|
|
12159
|
+
while (end < bytes.length && (bytes[end] & 0xc0) === 0x80) end -= 1
|
|
12160
|
+
var piece = decoder === null ? content : decoder.decode(bytes.subarray(offset, end))
|
|
12161
|
+
answer = await postWrite(Object.assign({}, payload, {
|
|
12162
|
+
content: piece,
|
|
12163
|
+
offset: offset,
|
|
12164
|
+
final: end >= bytes.length,
|
|
12165
|
+
}))
|
|
12166
|
+
offset = end
|
|
11903
12167
|
}
|
|
11904
|
-
return { mtimeMs:
|
|
12168
|
+
return { mtimeMs: answer === null ? undefined : answer.mtimeMs }
|
|
11905
12169
|
}
|
|
11906
12170
|
/**
|
|
11907
12171
|
* Workspace filename search — through THIS plugin's host route, which runs
|
|
@@ -11960,6 +12224,147 @@ var [ui, setUi] = useState(function () {
|
|
|
11960
12224
|
})
|
|
11961
12225
|
}
|
|
11962
12226
|
|
|
12227
|
+
/**
|
|
12228
|
+
* Whether `problem` is the AbortController's own rejection; the search effects
|
|
12229
|
+
* abort on every keystroke, so that is expected and must never surface as an
|
|
12230
|
+
* error line in the dropdown.
|
|
12231
|
+
* @param {unknown} problem - the caught value.
|
|
12232
|
+
* @returns {boolean} true for an abort.
|
|
12233
|
+
*/
|
|
12234
|
+
function isAbortError(problem) {
|
|
12235
|
+
return problem !== null && problem !== undefined && problem.name === 'AbortError'
|
|
12236
|
+
}
|
|
12237
|
+
|
|
12238
|
+
/**
|
|
12239
|
+
* Read one NDJSON search answer frame by frame.
|
|
12240
|
+
*
|
|
12241
|
+
* The host streams `start`, then one `page` per page of matches (in tree
|
|
12242
|
+
* order), then `done`. Rendering each page as it lands is the whole point:
|
|
12243
|
+
* the dropdown paints the first matches while the remaining repo roots are
|
|
12244
|
+
* still being listed (the batch route made the user wait for all of them).
|
|
12245
|
+
* @param {Response} response - the fetch answer (its body is a stream).
|
|
12246
|
+
* @param {(items: Array) => void} onPage - called with each page.
|
|
12247
|
+
* @returns {Promise<{matches: number, files: number, truncated: boolean}>} the `done` frame.
|
|
12248
|
+
*/
|
|
12249
|
+
async function readSearchStream(response, onPage) {
|
|
12250
|
+
var body = response.body
|
|
12251
|
+
if (body === null || body === undefined || typeof body.getReader !== 'function') {
|
|
12252
|
+
throw new Error('这个浏览器不支持流式读取')
|
|
12253
|
+
}
|
|
12254
|
+
var reader = body.getReader()
|
|
12255
|
+
var decoder = new TextDecoder()
|
|
12256
|
+
var buffer = ''
|
|
12257
|
+
var done = null
|
|
12258
|
+
function handleLine(line) {
|
|
12259
|
+
var text = line.trim()
|
|
12260
|
+
if (text === '') return
|
|
12261
|
+
var frame = null
|
|
12262
|
+
try { frame = JSON.parse(text) } catch (problem) { return }
|
|
12263
|
+
if (frame === null || typeof frame !== 'object') return
|
|
12264
|
+
if (frame.type === 'page' && Array.isArray(frame.items)) { onPage(frame.items); return }
|
|
12265
|
+
if (frame.type === 'error') throw new Error(typeof frame.message === 'string' ? frame.message : '检索失败')
|
|
12266
|
+
if (frame.type === 'done') {
|
|
12267
|
+
done = {
|
|
12268
|
+
matches: typeof frame.matches === 'number' ? frame.matches : 0,
|
|
12269
|
+
files: typeof frame.files === 'number' ? frame.files : 0,
|
|
12270
|
+
truncated: frame.truncated === true,
|
|
12271
|
+
}
|
|
12272
|
+
}
|
|
12273
|
+
}
|
|
12274
|
+
for (;;) {
|
|
12275
|
+
var chunk = await reader.read()
|
|
12276
|
+
if (chunk.done === true) break
|
|
12277
|
+
buffer += decoder.decode(chunk.value, { stream: true })
|
|
12278
|
+
var index = buffer.indexOf('\n')
|
|
12279
|
+
while (index !== -1) {
|
|
12280
|
+
handleLine(buffer.slice(0, index))
|
|
12281
|
+
buffer = buffer.slice(index + 1)
|
|
12282
|
+
index = buffer.indexOf('\n')
|
|
12283
|
+
}
|
|
12284
|
+
}
|
|
12285
|
+
buffer += decoder.decode()
|
|
12286
|
+
if (buffer !== '') handleLine(buffer)
|
|
12287
|
+
if (done === null) throw new Error('检索连接中断')
|
|
12288
|
+
return done
|
|
12289
|
+
}
|
|
12290
|
+
|
|
12291
|
+
/**
|
|
12292
|
+
* Streamed workspace filename search — pages arrive while the remaining repo
|
|
12293
|
+
* roots are still being listed, so the dropdown can paint the first hit long
|
|
12294
|
+
* before the batch route would have answered.
|
|
12295
|
+
* @param {{sessionId: string, cwd?: string}} scope - owning session.
|
|
12296
|
+
* @param {string} query - case-insensitive path/basename substring.
|
|
12297
|
+
* @param {{onPage?: Function}} handlers - receives each page of absolute paths.
|
|
12298
|
+
* @param {AbortSignal} [signal] - aborts the request when the query changes.
|
|
12299
|
+
* @returns {Promise<{matches: number, files: number, truncated: boolean}>} totals.
|
|
12300
|
+
*/
|
|
12301
|
+
async function fsSearchStream(scope, query, handlers, signal) {
|
|
12302
|
+
var url = routeUrl('dsh-ris-ide/search/stream')
|
|
12303
|
+
url.searchParams.set('sessionId', scope.sessionId)
|
|
12304
|
+
var routeCwd = scopeCwd(scope)
|
|
12305
|
+
if (routeCwd !== undefined) url.searchParams.set('cwd', routeCwd)
|
|
12306
|
+
url.searchParams.set('q', query)
|
|
12307
|
+
url.searchParams.set('limit', '300')
|
|
12308
|
+
url.searchParams.set('pageSize', String(SEARCH_STREAM_PAGE_SIZE))
|
|
12309
|
+
var onPage = handlers !== undefined && handlers !== null && typeof handlers.onPage === 'function'
|
|
12310
|
+
? handlers.onPage
|
|
12311
|
+
: function () {}
|
|
12312
|
+
var response = await fetch(url.href, { headers: { accept: 'application/x-ndjson' }, signal: signal })
|
|
12313
|
+
if (response.status === 404) {
|
|
12314
|
+
// A host older than 1.7.3 has no stream route yet (the client half reloads
|
|
12315
|
+
// with a page refresh, the host half only on `dsh web` restart). Answer the
|
|
12316
|
+
// batch route as ONE page instead of showing "HTTP 404" in the dropdown.
|
|
12317
|
+
var batch = await fsSearch(scope, query)
|
|
12318
|
+
onPage(batch.matches)
|
|
12319
|
+
return { matches: batch.matches.length, files: 0, truncated: false }
|
|
12320
|
+
}
|
|
12321
|
+
if (!response.ok) throw new Error('HTTP ' + response.status)
|
|
12322
|
+
return readSearchStream(response, onPage)
|
|
12323
|
+
}
|
|
12324
|
+
|
|
12325
|
+
/**
|
|
12326
|
+
* Streamed workspace CONTENT search (`git grep` hits), same page-by-page
|
|
12327
|
+
* contract as {@link fsSearchStream}.
|
|
12328
|
+
* @param {{sessionId: string, cwd?: string}} scope - owning session.
|
|
12329
|
+
* @param {string} query - literal text to find.
|
|
12330
|
+
* @param {{onPage?: Function}} handlers - receives each page of hits.
|
|
12331
|
+
* @param {AbortSignal} [signal] - aborts the request when the query changes.
|
|
12332
|
+
* @returns {Promise<{matches: number, files: number, truncated: boolean}>} totals.
|
|
12333
|
+
*/
|
|
12334
|
+
async function fsSearchContentStream(scope, query, handlers, signal) {
|
|
12335
|
+
var url = routeUrl('dsh-ris-ide/search-content/stream')
|
|
12336
|
+
url.searchParams.set('sessionId', scope.sessionId)
|
|
12337
|
+
var routeCwd = scopeCwd(scope)
|
|
12338
|
+
if (routeCwd !== undefined) url.searchParams.set('cwd', routeCwd)
|
|
12339
|
+
url.searchParams.set('q', query)
|
|
12340
|
+
url.searchParams.set('limit', '200')
|
|
12341
|
+
url.searchParams.set('pageSize', String(SEARCH_STREAM_PAGE_SIZE))
|
|
12342
|
+
var onPage = handlers !== undefined && handlers !== null && typeof handlers.onPage === 'function'
|
|
12343
|
+
? handlers.onPage
|
|
12344
|
+
: function () {}
|
|
12345
|
+
var response = await fetch(url.href, { headers: { accept: 'application/x-ndjson' }, signal: signal })
|
|
12346
|
+
if (response.status === 404) {
|
|
12347
|
+
// Pre-1.7.3 host: stream the batch route's hits as a single page.
|
|
12348
|
+
var hits = await fsSearchContent(scope, query)
|
|
12349
|
+
onPage(hits)
|
|
12350
|
+
return { matches: hits.length, files: 0, truncated: false }
|
|
12351
|
+
}
|
|
12352
|
+
if (!response.ok) throw new Error('HTTP ' + response.status)
|
|
12353
|
+
return readSearchStream(response, function (items) {
|
|
12354
|
+
var hits = []
|
|
12355
|
+
for (var index = 0; index < items.length; index += 1) {
|
|
12356
|
+
var hit = items[index]
|
|
12357
|
+
if (hit === null || hit === undefined || typeof hit.path !== 'string') continue
|
|
12358
|
+
hits.push({
|
|
12359
|
+
path: hit.path,
|
|
12360
|
+
line: typeof hit.line === 'number' ? hit.line : Number(hit.line) || 0,
|
|
12361
|
+
text: typeof hit.text === 'string' ? hit.text : '',
|
|
12362
|
+
})
|
|
12363
|
+
}
|
|
12364
|
+
onPage(hits)
|
|
12365
|
+
})
|
|
12366
|
+
}
|
|
12367
|
+
|
|
11963
12368
|
/**
|
|
11964
12369
|
* Work out what `mvn test` call would run one Java test FILE (PM gap #6).
|
|
11965
12370
|
*
|
|
@@ -12120,6 +12525,12 @@ var [ui, setUi] = useState(function () {
|
|
|
12120
12525
|
*/
|
|
12121
12526
|
/** How many query → results pairs the search dropdown keeps warm. */
|
|
12122
12527
|
var SEARCH_CACHE_LIMIT = 40
|
|
12528
|
+
/**
|
|
12529
|
+
* Matches per streamed page. The host flushes a page as soon as it fills, so
|
|
12530
|
+
* a small page is what makes the first hits visible while the remaining repo
|
|
12531
|
+
* roots are still being listed (the batch route had to finish all of them).
|
|
12532
|
+
*/
|
|
12533
|
+
var SEARCH_STREAM_PAGE_SIZE = 40
|
|
12123
12534
|
|
|
12124
12535
|
/**
|
|
12125
12536
|
* Remember one search result set (or refresh an existing key's position).
|
|
@@ -13664,6 +14075,11 @@ var [ui, setUi] = useState(function () {
|
|
|
13664
14075
|
searchHitActiveIndex: searchHitActiveIndex,
|
|
13665
14076
|
rememberSearchEntry: rememberSearchEntry,
|
|
13666
14077
|
fsSearchContent: fsSearchContent,
|
|
14078
|
+
fsSearchStream: fsSearchStream,
|
|
14079
|
+
fsSearchContentStream: fsSearchContentStream,
|
|
14080
|
+
readSearchStream: readSearchStream,
|
|
14081
|
+
isAbortError: isAbortError,
|
|
14082
|
+
SEARCH_STREAM_PAGE_SIZE: SEARCH_STREAM_PAGE_SIZE,
|
|
13667
14083
|
runTestStart: runTestStart,
|
|
13668
14084
|
runTestStatus: runTestStatus,
|
|
13669
14085
|
/**
|
|
@@ -13686,6 +14102,7 @@ var [ui, setUi] = useState(function () {
|
|
|
13686
14102
|
readSavedUi: readSavedUi,
|
|
13687
14103
|
treeLabel: treeLabel,
|
|
13688
14104
|
childEntryFor: childEntryFor,
|
|
14105
|
+
pathWithin: pathWithin,
|
|
13689
14106
|
sourceRelativeSuffix: sourceRelativeSuffix,
|
|
13690
14107
|
parseGutterLine: parseGutterLine,
|
|
13691
14108
|
// Log level filter (PM gap #4) and the "what did I change" diff (#5): both
|