dsh-ris-ide 1.6.11 → 1.7.1
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/README.md +25 -22
- package/lib/client-codemirror.js +309 -35
- package/lib/client.js +3193 -392
- package/lib/index.js +1635 -54
- package/lib/standalone/window.html +89 -14
- package/package.json +1 -1
- package/skills/dsh-ris-ide-debug/SKILL.md +2 -2
- package/test/client-viewer.test.mjs +834 -63
- package/test/clipboard.test.mjs +254 -0
- package/test/host-search.test.mjs +383 -0
- package/test/host-tail.test.mjs +136 -21
- package/test/windows.test.mjs +198 -0
|
@@ -193,7 +193,7 @@ test('only invisible outcomes and failures raise a toast', async () => {
|
|
|
193
193
|
}
|
|
194
194
|
// Failures and warnings keep their toast (nothing else would tell the user).
|
|
195
195
|
for (const kept of ['保存失败:', '启动失败:', '停止失败:', '加断点失败:', '删断点失败:',
|
|
196
|
-
'清断点失败:', '撤销失败:', '
|
|
196
|
+
'清断点失败:', '撤销失败:', ' 项失败:', '粘贴失败:', '新建文件失败:',
|
|
197
197
|
'取线程失败:', '取栈失败:', '取变量失败:', '文件不存在,已从最近历史移除:',
|
|
198
198
|
'已复制路径:', '已复制文件名:']) {
|
|
199
199
|
assert.ok(source.includes(kept), `${kept} must stay`)
|
|
@@ -447,19 +447,22 @@ test('apply adds a Session-header button immediately right of DSH\'s open-in-app
|
|
|
447
447
|
}
|
|
448
448
|
})
|
|
449
449
|
|
|
450
|
-
test('openStandaloneWindow hands the scope to the plugin\'s own page', () => {
|
|
450
|
+
test('openStandaloneWindow hands the scope to the plugin\'s own page', async () => {
|
|
451
451
|
const previousWindow = globalThis.window
|
|
452
452
|
const previousDocument = globalThis.document
|
|
453
|
+
const previousFetch = globalThis.fetch
|
|
453
454
|
const opened = []
|
|
454
455
|
globalThis.window = {
|
|
455
456
|
open: (...args) => { opened.push(args); return { focus() {} } },
|
|
456
457
|
}
|
|
457
458
|
globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
|
|
459
|
+
// No window registered for this workspace yet: the opener creates it.
|
|
460
|
+
globalThis.fetch = async () => ({ ok: false, status: 404, json: async () => ({}) })
|
|
458
461
|
try {
|
|
459
|
-
T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1' })
|
|
462
|
+
const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1' })
|
|
460
463
|
assert.equal(opened.length, 1)
|
|
461
|
-
const [
|
|
462
|
-
const parsed = new URL(
|
|
464
|
+
const [openedUrl, name, features] = opened[0]
|
|
465
|
+
const parsed = new URL(openedUrl)
|
|
463
466
|
// Same origin as the DSH page: no new port, cookie auth comes along.
|
|
464
467
|
assert.equal(parsed.origin, 'http://127.0.0.1:3080')
|
|
465
468
|
assert.equal(parsed.pathname, '/dsh-ris-ide/window')
|
|
@@ -467,6 +470,7 @@ test('openStandaloneWindow hands the scope to the plugin\'s own page', () => {
|
|
|
467
470
|
assert.equal(parsed.searchParams.get('cwd'), '/w/project')
|
|
468
471
|
assert.equal(parsed.searchParams.get('programId'), 'p1')
|
|
469
472
|
assert.equal(parsed.searchParams.get('debug'), null, 'plain open: no auto-debug')
|
|
473
|
+
assert.notEqual(handle, null, 'the created window is handed back')
|
|
470
474
|
// One IDE window per workspace: the name is derived from the cwd, so a
|
|
471
475
|
// second click on the same workspace reuses this window, while another
|
|
472
476
|
// workspace keeps its own window.
|
|
@@ -476,31 +480,144 @@ test('openStandaloneWindow hands the scope to the plugin\'s own page', () => {
|
|
|
476
480
|
// A program-subdirectory cwd roots the panel there, but the WINDOW still
|
|
477
481
|
// follows the workspace (`windowCwd`), so it never opens a second window.
|
|
478
482
|
globalThis.window.localStorage = { getItem: () => '/w/project' }
|
|
479
|
-
T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project/sub', programId: 'p1' })
|
|
483
|
+
await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project/sub', programId: 'p1' })
|
|
480
484
|
const scoped = new URL(opened[opened.length - 1][0])
|
|
481
485
|
assert.equal(scoped.searchParams.get('cwd'), '/w/project/sub', 'the panel keeps its rooted cwd')
|
|
482
486
|
assert.equal(opened[opened.length - 1][1], T.standaloneWindowName('/w/project'), 'the window name stays workspace-keyed')
|
|
483
487
|
assert.match(features, /popup=yes/)
|
|
484
488
|
// The compact panel's 🐞 button: same window, plus "start the JDWP session".
|
|
485
|
-
T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1', debug: true })
|
|
489
|
+
await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project', programId: 'p1', debug: true })
|
|
486
490
|
assert.equal(new URL(opened[opened.length - 1][0]).searchParams.get('debug'), '1')
|
|
487
491
|
} finally {
|
|
488
492
|
globalThis.window = previousWindow
|
|
489
493
|
globalThis.document = previousDocument
|
|
494
|
+
globalThis.fetch = previousFetch
|
|
490
495
|
}
|
|
491
496
|
})
|
|
492
497
|
|
|
493
|
-
test('
|
|
498
|
+
test('an already-open window is asked to close before a fresh one is opened', async () => {
|
|
494
499
|
const previousWindow = globalThis.window
|
|
495
500
|
const previousDocument = globalThis.document
|
|
501
|
+
const previousFetch = globalThis.fetch
|
|
502
|
+
const previousChannel = globalThis.BroadcastChannel
|
|
503
|
+
const opened = []
|
|
504
|
+
const messages = []
|
|
505
|
+
const windowName = T.standaloneWindowName('/w/project')
|
|
506
|
+
let alive = true
|
|
507
|
+
globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
|
|
508
|
+
globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
|
|
509
|
+
globalThis.fetch = async () => ({
|
|
510
|
+
ok: true,
|
|
511
|
+
status: 200,
|
|
512
|
+
json: async () => ({ ok: true, windows: [{ name: windowName, cwd: '/w/project', alive, idleMs: 12 }], session: null }),
|
|
513
|
+
})
|
|
514
|
+
globalThis.BroadcastChannel = class {
|
|
515
|
+
constructor(name) { this.name = name; this.onmessage = null }
|
|
516
|
+
postMessage(message) {
|
|
517
|
+
messages.push({ name: this.name, message })
|
|
518
|
+
// The old window obeys: it closes itself, so its stream disappears.
|
|
519
|
+
if (message !== null && message.type === 'close') alive = false
|
|
520
|
+
}
|
|
521
|
+
close() {}
|
|
522
|
+
}
|
|
523
|
+
try {
|
|
524
|
+
const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project' })
|
|
525
|
+
assert.notEqual(handle, null, 'the click always ends with a window')
|
|
526
|
+
assert.equal(opened.length, 1, 'exactly one window is opened — after the old one is gone, no twin')
|
|
527
|
+
assert.equal(new URL(opened[0][0]).pathname, '/dsh-ris-ide/window')
|
|
528
|
+
assert.equal(opened[0][1], windowName, 'the window name is workspace-keyed')
|
|
529
|
+
assert.deepEqual(messages, [{ name: windowName, message: { type: 'close' } }], 'the old window is asked to close, not raised')
|
|
530
|
+
} finally {
|
|
531
|
+
globalThis.window = previousWindow
|
|
532
|
+
globalThis.document = previousDocument
|
|
533
|
+
globalThis.fetch = previousFetch
|
|
534
|
+
globalThis.BroadcastChannel = previousChannel
|
|
535
|
+
}
|
|
536
|
+
})
|
|
537
|
+
|
|
538
|
+
test('a window that refuses to close does not block the new one', async () => {
|
|
539
|
+
const previousWindow = globalThis.window
|
|
540
|
+
const previousDocument = globalThis.document
|
|
541
|
+
const previousFetch = globalThis.fetch
|
|
542
|
+
const previousChannel = globalThis.BroadcastChannel
|
|
543
|
+
const opened = []
|
|
544
|
+
const messages = []
|
|
545
|
+
const windowName = T.standaloneWindowName('/w/project')
|
|
546
|
+
globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
|
|
547
|
+
globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
|
|
548
|
+
// It stays alive: the old window ignored the close ping (a frozen tab, say).
|
|
549
|
+
globalThis.fetch = async () => ({
|
|
550
|
+
ok: true,
|
|
551
|
+
status: 200,
|
|
552
|
+
json: async () => ({ ok: true, windows: [{ name: windowName, cwd: '/w/project', alive: true, idleMs: 8 }], session: null }),
|
|
553
|
+
})
|
|
554
|
+
globalThis.BroadcastChannel = class {
|
|
555
|
+
constructor(name) { this.name = name; this.onmessage = null }
|
|
556
|
+
postMessage(message) { messages.push({ name: this.name, message }) }
|
|
557
|
+
close() {}
|
|
558
|
+
}
|
|
559
|
+
try {
|
|
560
|
+
const started = Date.now()
|
|
561
|
+
const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project' })
|
|
562
|
+
assert.notEqual(handle, null, 'the click still ends with a window')
|
|
563
|
+
assert.equal(opened.length, 1)
|
|
564
|
+
assert.deepEqual(messages.map((entry) => entry.message.type), ['close'], 'the close ping is the only message')
|
|
565
|
+
assert.ok(Date.now() - started >= 1400, 'it waited for the closing handshake before giving up')
|
|
566
|
+
} finally {
|
|
567
|
+
globalThis.window = previousWindow
|
|
568
|
+
globalThis.document = previousDocument
|
|
569
|
+
globalThis.fetch = previousFetch
|
|
570
|
+
globalThis.BroadcastChannel = previousChannel
|
|
571
|
+
}
|
|
572
|
+
})
|
|
573
|
+
|
|
574
|
+
test('a closed window never blocks the next open (dead registrations do not wait)', async () => {
|
|
575
|
+
const previousWindow = globalThis.window
|
|
576
|
+
const previousDocument = globalThis.document
|
|
577
|
+
const previousFetch = globalThis.fetch
|
|
578
|
+
const previousChannel = globalThis.BroadcastChannel
|
|
579
|
+
const opened = []
|
|
580
|
+
const messages = []
|
|
581
|
+
globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
|
|
582
|
+
globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
|
|
583
|
+
globalThis.fetch = async () => ({
|
|
584
|
+
ok: true,
|
|
585
|
+
status: 200,
|
|
586
|
+
json: async () => ({ ok: true, windows: [{ name: T.standaloneWindowName('/w/project'), cwd: '/w/project', alive: false, idleMs: 5000 }], session: null }),
|
|
587
|
+
})
|
|
588
|
+
globalThis.BroadcastChannel = class {
|
|
589
|
+
constructor(name) { this.name = name; this.onmessage = null }
|
|
590
|
+
postMessage(message) { messages.push({ name: this.name, message }) }
|
|
591
|
+
close() {}
|
|
592
|
+
}
|
|
593
|
+
try {
|
|
594
|
+
const started = Date.now()
|
|
595
|
+
const handle = await T.openStandaloneWindow({ sessionId: 's1', cwd: '/w/project' })
|
|
596
|
+
assert.notEqual(handle, null, 'a registration whose stream is gone must not block opening')
|
|
597
|
+
assert.equal(opened.length, 1)
|
|
598
|
+
assert.deepEqual(messages, [], 'no close ping: there is nobody to close')
|
|
599
|
+
assert.ok(Date.now() - started < 850, 'no pointless wait for a window that is already gone')
|
|
600
|
+
} finally {
|
|
601
|
+
globalThis.window = previousWindow
|
|
602
|
+
globalThis.document = previousDocument
|
|
603
|
+
globalThis.fetch = previousFetch
|
|
604
|
+
globalThis.BroadcastChannel = previousChannel
|
|
605
|
+
}
|
|
606
|
+
})
|
|
607
|
+
|
|
608
|
+
test('openStandaloneWindow asks for the whole screen work area (maximized)', async () => {
|
|
609
|
+
const previousWindow = globalThis.window
|
|
610
|
+
const previousDocument = globalThis.document
|
|
611
|
+
const previousFetch = globalThis.fetch
|
|
496
612
|
const opened = []
|
|
497
613
|
globalThis.window = {
|
|
498
614
|
screen: { availWidth: 1920, availHeight: 1040 },
|
|
499
615
|
open: (...args) => { opened.push(args); return { focus() {} } },
|
|
500
616
|
}
|
|
501
617
|
globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
|
|
618
|
+
globalThis.fetch = async () => ({ ok: false, status: 404, json: async () => ({}) })
|
|
502
619
|
try {
|
|
503
|
-
T.openStandaloneWindow({ sessionId: 's1' })
|
|
620
|
+
await T.openStandaloneWindow({ sessionId: 's1' })
|
|
504
621
|
const features = opened[0][2]
|
|
505
622
|
assert.match(features, /width=1920/, 'the work area width, not a fixed width')
|
|
506
623
|
assert.match(features, /height=1040/, 'the work area height, not a fixed height')
|
|
@@ -509,24 +626,28 @@ test('openStandaloneWindow asks for the whole screen work area (maximized)', ()
|
|
|
509
626
|
assert.match(features, /popup=yes/)
|
|
510
627
|
// No screen information (odd hosts): keep the old fallback instead of NaN.
|
|
511
628
|
globalThis.window = { open: (...args) => { opened.push(args); return { focus() {} } } }
|
|
512
|
-
T.openStandaloneWindow({ sessionId: 's1' })
|
|
629
|
+
await T.openStandaloneWindow({ sessionId: 's1' })
|
|
513
630
|
assert.match(opened[1][2], /width=1500/)
|
|
514
631
|
} finally {
|
|
515
632
|
globalThis.window = previousWindow
|
|
516
633
|
globalThis.document = previousDocument
|
|
634
|
+
globalThis.fetch = previousFetch
|
|
517
635
|
}
|
|
518
636
|
})
|
|
519
637
|
|
|
520
|
-
test('openStandaloneWindow reports a blocked popup instead of failing silently', () => {
|
|
638
|
+
test('openStandaloneWindow reports a blocked popup instead of failing silently', async () => {
|
|
521
639
|
const previousWindow = globalThis.window
|
|
522
640
|
const previousDocument = globalThis.document
|
|
641
|
+
const previousFetch = globalThis.fetch
|
|
523
642
|
globalThis.window = { open: () => null }
|
|
524
643
|
globalThis.document = { baseURI: 'http://127.0.0.1:3080/' }
|
|
644
|
+
globalThis.fetch = async () => ({ ok: false, status: 404, json: async () => ({}) })
|
|
525
645
|
try {
|
|
526
|
-
assert.
|
|
646
|
+
await assert.rejects(T.openStandaloneWindow({ sessionId: 's1' }), /被拦截/)
|
|
527
647
|
} finally {
|
|
528
648
|
globalThis.window = previousWindow
|
|
529
649
|
globalThis.document = previousDocument
|
|
650
|
+
globalThis.fetch = previousFetch
|
|
530
651
|
}
|
|
531
652
|
})
|
|
532
653
|
|
|
@@ -545,11 +666,10 @@ test('mountStandalone renders the IDE panel with no DSH context at all', async (
|
|
|
545
666
|
// The panel sits under the error boundary, so one render error cannot blank
|
|
546
667
|
// the window; the boundary itself is the outermost component.
|
|
547
668
|
assert.equal(element.type, T.IdeErrorBoundary, 'the panel is wrapped in the error boundary')
|
|
548
|
-
const
|
|
549
|
-
assert.equal(
|
|
550
|
-
assert.equal(
|
|
551
|
-
assert.equal(
|
|
552
|
-
assert.equal(panel.props.visible, true)
|
|
669
|
+
const windowRoot = element.props.children
|
|
670
|
+
assert.equal(windowRoot.type, T.StandaloneWindow, 'the window root owns the scope it can change')
|
|
671
|
+
assert.equal(windowRoot.props.sessionId, 's1')
|
|
672
|
+
assert.equal(windowRoot.props.cwd, '/w/project')
|
|
553
673
|
} finally {
|
|
554
674
|
globalThis.window = previousWindow
|
|
555
675
|
globalThis.document = previousDocument
|
|
@@ -643,7 +763,7 @@ async function withLogServer(run) {
|
|
|
643
763
|
res.writeHead(state.disableConfig ? 409 : 200, { 'content-type': 'application/json' })
|
|
644
764
|
res.end(JSON.stringify(state.disableConfig
|
|
645
765
|
? { ok: false, code: 'config-exists', message: 'exists' }
|
|
646
|
-
: { ok: true, path: '/w/.dsh-ris-ide.json', count: 3, mode: state.configBody.mode ?? 'generate' }))
|
|
766
|
+
: { ok: true, path: '/w/.dsh-ris-ide/config.json', count: 3, mode: state.configBody.mode ?? 'generate' }))
|
|
647
767
|
})
|
|
648
768
|
return
|
|
649
769
|
}
|
|
@@ -919,7 +1039,7 @@ test('generateConfig asks the host to write or update the config', async () => {
|
|
|
919
1039
|
const scope = { sessionId: 's1', cwd: '/w' }
|
|
920
1040
|
const generated = await T.generateConfig(scope)
|
|
921
1041
|
assert.equal(generated.ok, true)
|
|
922
|
-
assert.equal(generated.path, '/w/.dsh-ris-ide.json')
|
|
1042
|
+
assert.equal(generated.path, '/w/.dsh-ris-ide/config.json')
|
|
923
1043
|
assert.equal(generated.mode, 'generate')
|
|
924
1044
|
assert.equal(state.configCalls, 1)
|
|
925
1045
|
assert.deepEqual(state.configBody, { sessionId: 's1', cwd: '/w' })
|
|
@@ -1286,17 +1406,22 @@ test('the tree clipboard keys only fire while the tree owns the focus', async ()
|
|
|
1286
1406
|
})
|
|
1287
1407
|
|
|
1288
1408
|
// 1.6.10: Ctrl+C / Ctrl+X used to read the context-menu state only, so the
|
|
1289
|
-
// keyboard silently copied nothing
|
|
1290
|
-
//
|
|
1291
|
-
test('Ctrl+C copies the selected
|
|
1409
|
+
// keyboard silently copied nothing. 1.6.11: the tree is a multi-selection
|
|
1410
|
+
// (Ctrl+click / Ctrl+A), so the clipboard carries every selected row.
|
|
1411
|
+
test('Ctrl+C copies the selected rows without the context menu', async () => {
|
|
1292
1412
|
const { readFile } = await import('node:fs/promises')
|
|
1293
1413
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1294
|
-
assert.match(source, /var
|
|
1414
|
+
assert.match(source, /var seed = treeMenu !== null && treeMenu\.entry !== null && treeMenu\.entry !== undefined/,
|
|
1295
1415
|
'the context-menu entry still wins when the menu is open')
|
|
1296
|
-
assert.match(source, /: \(selectedPath === null \?
|
|
1416
|
+
assert.match(source, /: \(selectedPath === null \? '' : selectedPath\)/,
|
|
1297
1417
|
'the keyboard falls back to the tree selection')
|
|
1298
|
-
assert.match(source, /
|
|
1418
|
+
assert.match(source, /var paths = selectionFor\(seed\)/, 'a menu/key command expands to the whole selection')
|
|
1419
|
+
assert.match(source, /setClipboard\(\{ mode: mode, items: items \}\)/, 'the clipboard carries every selected row')
|
|
1299
1420
|
assert.match(source, /event\.key === 'a' \|\| event\.key === 'A'/, 'Ctrl+A is claimed while the tree owns the keys')
|
|
1421
|
+
assert.match(source, /var visible = visibleEntries\(\)/, 'Ctrl+A selects the visible rows')
|
|
1422
|
+
assert.match(source, /setSelectedPaths\(visible\.map\(function \(row\) \{ return row\.path \}\)\)/)
|
|
1423
|
+
// The page-wide text selection the old code leaked is gone: the tree handles it.
|
|
1424
|
+
assert.doesNotMatch(source, /The tree is single-selection, so 全选 has nothing to expand into/)
|
|
1300
1425
|
})
|
|
1301
1426
|
|
|
1302
1427
|
test('a file row is a drop target for the directory it lives in', async () => {
|
|
@@ -1304,7 +1429,9 @@ test('a file row is a drop target for the directory it lives in', async () => {
|
|
|
1304
1429
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1305
1430
|
assert.match(source, /var dropDir = entry\.isDir === true \? entry\.path : parentOf\(entry\.path\)/)
|
|
1306
1431
|
assert.match(source, /var isDropTarget = dropTarget === entry\.path/, 'file rows highlight too')
|
|
1307
|
-
assert.match(source, /void
|
|
1432
|
+
assert.match(source, /void moveEntriesInto\(paths, dropDir\)/, 'dropping on a file moves into its parent')
|
|
1433
|
+
assert.match(source, /setData\('application\/x-dsh-ris-ide-paths', JSON\.stringify\(dragged\)\)/, 'a drag carries the whole selection')
|
|
1434
|
+
assert.match(source, /function dragPaths\(transfer\)/, 'drops read the path list back')
|
|
1308
1435
|
assert.match(source, /void importExternal\(dropDir, external, \[\]\)/)
|
|
1309
1436
|
// The row handlers must not be dir-gated any more (the bug: `undefined` let the
|
|
1310
1437
|
// list container's "blank area = workspace root" drop swallow the event).
|
|
@@ -1312,6 +1439,105 @@ test('a file row is a drop target for the directory it lives in', async () => {
|
|
|
1312
1439
|
assert.doesNotMatch(source, /onDragOver: entry\.isDir === true \?/)
|
|
1313
1440
|
})
|
|
1314
1441
|
|
|
1442
|
+
// 1.7.1: 从系统桌面复制多个文件到文件树、目标目录里已有同名文件时,1.7.0 的
|
|
1443
|
+
// importExternal 在第一个同名冲突处 `break`,后面的文件被静默丢弃(用户看到「只复制了
|
|
1444
|
+
// 一个」)。批量导入现在先落地其余文件,把同名的收集进同一张「覆盖 / 生成副本」卡片;
|
|
1445
|
+
// 只有单个文件时才保留「粘贴为」改名卡。files 与 text/uri-list 也必须一起读——有些
|
|
1446
|
+
// 桌面只投递文本,只读 files 会再次丢文件。
|
|
1447
|
+
test('pasting several OS files never stops at the first existing name', async () => {
|
|
1448
|
+
const { readFile } = await import('node:fs/promises')
|
|
1449
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1450
|
+
// The batch loop no longer abandons the rest of the paste on a collision.
|
|
1451
|
+
assert.doesNotMatch(source, /if \(created === undefined\) break/,
|
|
1452
|
+
'a 同名 collision must not drop every file after it')
|
|
1453
|
+
assert.match(source, /async function importOne\(source, dir, name, overwrite\)/)
|
|
1454
|
+
assert.match(source, /async function importOneWithCopyName\(source, dir\)/)
|
|
1455
|
+
assert.match(source, /var name = attempt === 0 \? source\.name : collisionCopyName\(source\.name, false, attempt\)/,
|
|
1456
|
+
'生成副本 reuses the batch suffix rule')
|
|
1457
|
+
// ONE file keeps the 粘贴为 card; MANY collect the collisions into the batch card.
|
|
1458
|
+
assert.match(source, /if \(sources\.length === 1\) \{\n\s+\/\/ A single pasted file: the collision is a choice, not a batch\.\n\s+parkPasteName\(source, trimmedDir, source\.name\)/)
|
|
1459
|
+
assert.match(source, /items: conflicts, created: created,\n\s+origins: \[\], touched: \[trimmedDir\], external: true,/,
|
|
1460
|
+
'the external collisions park the same 覆盖 / 生成副本 card')
|
|
1461
|
+
assert.match(source, /if \(pending\.external === true\) \{/, 'the batch card knows how to place a pasted blob/path')
|
|
1462
|
+
assert.match(source, /created\.push\(await importOne\(item, pending\.dir, item\.name, true\)\)/, '覆盖 re-sends the pasted bytes')
|
|
1463
|
+
assert.match(source, /var placedExternal = await importOneWithCopyName\(item, pending\.dir\)/, '生成副本 re-sends under a suffixed name')
|
|
1464
|
+
// files AND the URI list are read together; a name delivered as both is imported once.
|
|
1465
|
+
assert.match(source, /if \(files\.length > 0 \|\| paths\.length > 0\) \{/,
|
|
1466
|
+
'a payload with files or paths goes through the tree paste path')
|
|
1467
|
+
assert.match(source, /void pasteFromOsClipboard\(text\)/,
|
|
1468
|
+
'an empty payload asks the Host what the OS clipboard holds')
|
|
1469
|
+
assert.match(source, /void importExternal\(pasteTargetDir\(\), files, paths\)/)
|
|
1470
|
+
assert.match(source, /if \(fileName === '' \|\| seen\[fileName\] === true\) continue/)
|
|
1471
|
+
assert.match(source, /if \(leaf === '' \|\| seen\[leaf\] === true\) continue/)
|
|
1472
|
+
})
|
|
1473
|
+
|
|
1474
|
+
// 1.7.1: 树里按 Ctrl+C(内部剪贴板非空)之后,在资源管理器复制别的文件、再回树里
|
|
1475
|
+
// Ctrl+V —— keydown 曾经直接 preventDefault + pasteInto(内部剪贴板),浏览器根本不发
|
|
1476
|
+
// paste 事件,粘出来的是「之前复制出去的那批文件」(源文件已删就报不存在)。现在 OS
|
|
1477
|
+
// 剪贴板优先:keydown 只兜底,paste 事件先到先按外部内容导入;只有同名同数量的那批
|
|
1478
|
+
// 才是回头的自家剪贴板,仍走树内语义(剪切 = 移动)。
|
|
1479
|
+
test('an OS clipboard paste wins over a stale tree clipboard', async () => {
|
|
1480
|
+
const { readFile } = await import('node:fs/promises')
|
|
1481
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1482
|
+
// The keydown no longer claims the gesture when our own clipboard is non-empty…
|
|
1483
|
+
assert.match(source, /if \(clipboard === null\) return\n\s+\/\/ A text field owns Ctrl\+V/,
|
|
1484
|
+
'the tree clipboard no longer swallows Ctrl+V outright')
|
|
1485
|
+
assert.match(source, /if \(isTextEntry\(event\.target\)\) return/, 'an editor keeps its native paste')
|
|
1486
|
+
// …it waits one beat, so an empty OS clipboard still pastes the tree clipboard.
|
|
1487
|
+
assert.match(source, /var askedAt = Date\.now\(\)/)
|
|
1488
|
+
assert.match(source, /if \(pasteAtRef\.current >= askedAt\) return/)
|
|
1489
|
+
// The paste handler decides: our own copy keeps the tree semantics, anything else imports.
|
|
1490
|
+
assert.match(source, /pasteAtRef\.current = Date\.now\(\)/, 'the paste event stands the fallback down')
|
|
1491
|
+
assert.match(source, /if \(clipboard !== null && isTreeClipboardCopy\(files, paths\)\) \{/,
|
|
1492
|
+
'our own copy is confirmed against the Host before it takes the tree path')
|
|
1493
|
+
assert.match(source, /function isTreeClipboardCopy\(files, paths\) \{/)
|
|
1494
|
+
assert.match(source, /function isTextEntry\(node\) \{/)
|
|
1495
|
+
assert.match(source, /if \(own\.length === 0 \|\| seen\.length !== own\.length\) return false/,
|
|
1496
|
+
'a different file set is external content, not the tree clipboard')
|
|
1497
|
+
})
|
|
1498
|
+
|
|
1499
|
+
// 谁新谁赢:`beginCopy` 会把同一批写进系统剪贴板,所以粘贴负载与树内那批不同 ⇒
|
|
1500
|
+
// 系统剪贴板是后来复制的东西,树里的旧剪贴板作废(丢弃),绝不复活旧条目。
|
|
1501
|
+
test('a newer OS clipboard discards the older tree clipboard', async () => {
|
|
1502
|
+
const { readFile } = await import('node:fs/promises')
|
|
1503
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1504
|
+
assert.match(source, /\/\/ Different files than the tree copied[\s\S]{0,300}if \(clipboard !== null\) setClipboard\(null\)\n\s+void importExternal\(pasteTargetDir\(\), files, paths\)/)
|
|
1505
|
+
assert.match(source, /已清空文件树里的旧复制/)
|
|
1506
|
+
assert.match(source, /var newer = text\.trim\(\) !== '' \|\| \(host !== null && host\.text\.trim\(\) !== ''\)/)
|
|
1507
|
+
assert.match(source, /\/\/ No paste payload at all and nothing readable[\s\S]{0,200}void pasteInto\(pasteTargetDir\(\)\)/)
|
|
1508
|
+
})
|
|
1509
|
+
|
|
1510
|
+
// 桌面 → 文件树(WSL):Explorer 里的文件复制根本进不了 Chromium(WSLg 不桥接
|
|
1511
|
+
// Windows 的 CF_HDROP),paste 事件是空负载;此时由宿主读系统剪贴板,拿真实文件
|
|
1512
|
+
// 列表走 /fs/import。宿主的读数同时用来判断树里那份旧剪贴板是否还有效。
|
|
1513
|
+
test('a desktop copy reaches the tree through the Host clipboard', async () => {
|
|
1514
|
+
const { readFile } = await import('node:fs/promises')
|
|
1515
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1516
|
+
assert.match(source, /void pasteFromOsClipboard\(text\)/, 'an empty payload asks the Host')
|
|
1517
|
+
assert.match(source, /async function fsClipboardState\(scope\) \{[\s\S]{0,400}'dsh-ris-ide\/clipboard\/read'/)
|
|
1518
|
+
assert.match(source, /var host = await readHostClipboard\(\)/)
|
|
1519
|
+
assert.match(source, /if \(clipboard !== null && samePathList\(host\.files, clipboardItems\(\)\)\) \{/,
|
|
1520
|
+
'our own copy stays on the tree path')
|
|
1521
|
+
assert.match(source, /void importExternal\(pasteTargetDir\(\), \[\], host\.files\)/,
|
|
1522
|
+
'files the page cannot see are imported from the Host list')
|
|
1523
|
+
assert.match(source, /function samePathList\(files, items\) \{/)
|
|
1524
|
+
assert.match(source, /function trimTrailingSeparator\(path\) \{/)
|
|
1525
|
+
})
|
|
1526
|
+
|
|
1527
|
+
// 系统剪贴板只投递 `text/uri-list`(没有 File blob)时走 `/fs/import`:宿主读的是
|
|
1528
|
+
// `from` = 源文件、`dir` = 目标目录。两个调用点曾把两者写反(from=目标目录、
|
|
1529
|
+
// dir=源文件),于是粘贴报「粘贴目标不是目录」,文件一个都落不下来。
|
|
1530
|
+
test('a path paste sends the source as `from` and the folder as `dir`', async () => {
|
|
1531
|
+
const { readFile } = await import('node:fs/promises')
|
|
1532
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1533
|
+
assert.match(source, /async function fsImportPath\(scope, sourcePath, dir, name, overwrite\)/)
|
|
1534
|
+
assert.match(source, /\{ from: sourcePath, dir: dir, name: name, overwrite: overwrite === true \}/)
|
|
1535
|
+
assert.match(source, /await fsImportPath\(scope, source\.path, trimmedDir, name, overwrite === true\)/)
|
|
1536
|
+
assert.match(source, /await fsImportPath\(scope, source\.path, dir, name, replace\)/)
|
|
1537
|
+
assert.doesNotMatch(source, /fsImportPath\(scope, dir, source\.path/)
|
|
1538
|
+
assert.doesNotMatch(source, /fsImportPath\(scope, trimmedDir, source\.path/)
|
|
1539
|
+
})
|
|
1540
|
+
|
|
1315
1541
|
test('a forced tree read asks the host for a fresh listing', async () => {
|
|
1316
1542
|
const { readFile } = await import('node:fs/promises')
|
|
1317
1543
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
@@ -1336,21 +1562,104 @@ test('the tree 复制 menu copies, while 创建副本 makes the duplicate', asyn
|
|
|
1336
1562
|
assert.match(source, /setPrompt\(\{ mode: 'duplicate'/)
|
|
1337
1563
|
assert.match(source, /setPromptName\(duplicateName\(/)
|
|
1338
1564
|
assert.match(source, /副本名称不能与原文件相同/)
|
|
1339
|
-
// A paste collision
|
|
1340
|
-
//
|
|
1341
|
-
// the tree
|
|
1342
|
-
assert.match(source, /function parkPasteName\(source, dir, name\)/)
|
|
1343
|
-
assert.match(source, /setPrompt\(\{ mode: 'paste', dir: dir, ext: '', title: '粘贴为', source: source, conflict: name \}\)/)
|
|
1344
|
-
assert.match(source, /setPromptName\(
|
|
1565
|
+
// A paste collision opens the 粘贴为 card with the REAL name (no 副本 prefill),
|
|
1566
|
+
// an explicit 覆盖 button, and inline 请改名 instead of a toast; the copy banner
|
|
1567
|
+
// at the top of the tree stays gone.
|
|
1568
|
+
assert.match(source, /function parkPasteName\(source, dir, name, forcedMode\)/)
|
|
1569
|
+
assert.match(source, /setPrompt\(\{ mode: 'paste', dir: dir, ext: '', title: '粘贴为', source: source, conflict: name, pasteMode: forcedMode \}\)/)
|
|
1570
|
+
assert.match(source, /setPromptName\(name\)\n\s+setPromptNotice\(''\)/, 'the colliding name is prefilled verbatim')
|
|
1571
|
+
assert.doesNotMatch(source, /setPromptName\(duplicateName\(name, false\)\)/, 'no hidden 副本 prefill any more')
|
|
1572
|
+
assert.match(source, /async function overwritePaste\(\)/, '覆盖 overwrites under the same name')
|
|
1573
|
+
assert.match(source, /'data-tree-prompt-overwrite': '1'/, 'the card offers 覆盖')
|
|
1574
|
+
assert.match(source, /setPromptNotice\('同名文件已存在,请改名(或点「覆盖」)'\)/, '确定 with the same name asks for a new one')
|
|
1345
1575
|
assert.match(source, /if \(prompt\.conflict !== undefined && name === prompt\.conflict\)/)
|
|
1346
1576
|
assert.match(source, /if \(isExistsProblem\(problem\)\) \{\n\s+parkPasteName\(source, dir, name\)/)
|
|
1347
1577
|
assert.doesNotMatch(source, /data-tree-paste-conflict/)
|
|
1348
1578
|
assert.doesNotMatch(source, /data-tree-clipboard/)
|
|
1349
1579
|
// A COPY onto its own path is a duplicate request (falls through to the prompt),
|
|
1350
1580
|
// while CUT → its own folder stays a silent no-op.
|
|
1351
|
-
assert.match(source, /if \(source\.kind === 'clipboard' && target === from &&
|
|
1581
|
+
assert.match(source, /if \(source\.kind === 'clipboard' && target === from && mode !== 'copy'\)/)
|
|
1352
1582
|
// …and moving an entry into its own folder stays a silent no-op.
|
|
1353
|
-
assert.match(source, /if \(from ===
|
|
1583
|
+
assert.match(source, /if \(from === trimmedDir \|\| parentOf\(from\) === trimmedDir\) continue/)
|
|
1584
|
+
})
|
|
1585
|
+
|
|
1586
|
+
// 1.6.11: 文件树多选 + 批量操作。Ctrl+点击 标记行、Ctrl+A 全选可见行;粘贴/移动把
|
|
1587
|
+
// 所有标记行放进目标目录,重名自动后缀「 副本」「 副本(n)」并用一条提示说明(批量
|
|
1588
|
+
// 操作绝不逐个弹窗),批量删除同样一条 Ctrl+Z 撤销。
|
|
1589
|
+
test('multi-selection batches copy/move and suffix colliding names', async () => {
|
|
1590
|
+
// Pure naming/toggle helpers (unit level).
|
|
1591
|
+
assert.equal(T.collisionCopyName('A.java', false, 1), 'A 副本.java')
|
|
1592
|
+
assert.equal(T.collisionCopyName('A.java', false, 2), 'A 副本(2).java')
|
|
1593
|
+
assert.equal(T.collisionCopyName('Main.vue', false, 3), 'Main 副本(3).vue')
|
|
1594
|
+
assert.equal(T.collisionCopyName('Makefile', false, 1), 'Makefile 副本')
|
|
1595
|
+
assert.equal(T.collisionCopyName('.gitignore', false, 1), '.gitignore 副本')
|
|
1596
|
+
assert.equal(T.collisionCopyName('pkg', true, 1), 'pkg 副本')
|
|
1597
|
+
assert.equal(T.collisionCopyName('pkg', true, 2), 'pkg 副本(2)')
|
|
1598
|
+
assert.equal(T.collisionCopyName('', false, 1), 'copy')
|
|
1599
|
+
assert.deepEqual(T.toggleTreeSelection([], '/a'), ['/a'])
|
|
1600
|
+
assert.deepEqual(T.toggleTreeSelection(['/a'], '/a'), [])
|
|
1601
|
+
assert.deepEqual(T.toggleTreeSelection(['/a', '/b'], '/b'), ['/a'])
|
|
1602
|
+
assert.deepEqual(T.toggleTreeSelection(['/a'], '/b'), ['/a', '/b'])
|
|
1603
|
+
const { readFile } = await import('node:fs/promises')
|
|
1604
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1605
|
+
// Ctrl+click toggles membership; it must not open a file nor expand a folder.
|
|
1606
|
+
assert.match(source, /var additive = event\.ctrlKey === true \|\| event\.metaKey === true/)
|
|
1607
|
+
assert.match(source, /var next = toggleTreeSelection\(selectedPaths, entry\.path\)/)
|
|
1608
|
+
// Multi rows are drawn apart from the primary row.
|
|
1609
|
+
assert.match(source, /'data-tree-multi': isMulti \? '1' : undefined/)
|
|
1610
|
+
assert.match(source, /treeRowMulti:/)
|
|
1611
|
+
// Batch paste: one collision → one `… 副本`, no dialog in the loop.
|
|
1612
|
+
assert.match(source, /async function pasteBatch\(items, dir, mode\)/)
|
|
1613
|
+
assert.match(source, /async function pasteEntryInto\(item, dir, mode, ask\)/)
|
|
1614
|
+
assert.match(source, /var name = attempt === 0 \? item\.name : collisionCopyName\(item\.name, item\.isDir === true, attempt\)/)
|
|
1615
|
+
assert.match(source, /if \(!isExistsProblem\(problem\)\) throw problem/)
|
|
1616
|
+
assert.match(source, /function notifyCollisionCopies\(renamed, failures\)/)
|
|
1617
|
+
assert.match(source, /存在同名文件,已生成/)
|
|
1618
|
+
assert.match(source, /await pasteBatch\(clipboardItems\(\), dir, mode === 'copy' \? 'copy' : 'cut'\)/)
|
|
1619
|
+
// Batch move (drag) uses the same collision rule.
|
|
1620
|
+
assert.match(source, /async function moveEntriesInto\(paths, dirPath\)/)
|
|
1621
|
+
assert.match(source, /await pasteEntryInto\(\{ path: from, isDir: isDir, name: fileBaseName\(from\) \}, dirPath, 'cut', true\)/, 'a drag surfaces collisions instead of silently renaming')
|
|
1622
|
+
assert.match(source, /if \(placed\.conflict === true\) \{\n\s+if \(paths\.length === 1\) \{\n\s+parkPasteName\(\{ kind: 'entry'/, 'a single drag collision parks the 粘贴为 card')
|
|
1623
|
+
assert.match(source, /conflicts\.push\(\{ path: from, isDir: isDir, name: fileBaseName\(from\) \}\)/, 'a batch drag collects the collisions')
|
|
1624
|
+
assert.match(source, /if \(ask === true && attempt === 0\) return \{ path: target, conflict: true, renamed: false \}/)
|
|
1625
|
+
assert.match(source, /var mode = forcedMode === 'cut' \|\| forcedMode === 'copy' \? forcedMode/, 'a parked drag keeps its cut semantics')
|
|
1626
|
+
// Batch collisions ask 覆盖 / 生成副本 (no name field) instead of suffixing silently.
|
|
1627
|
+
assert.match(source, /var \[batchConflict, setBatchConflict\] = useState\(null\)/)
|
|
1628
|
+
assert.match(source, /setBatchConflict\(\{ mode: mode, dir: trimmedDir, items: conflicts, created: created, origins: origins, touched: touched \}\)/)
|
|
1629
|
+
assert.match(source, /'data-tree-batch-conflict': '1'/)
|
|
1630
|
+
assert.match(source, /'data-tree-batch-overwrite': '1'/, '覆盖 replaces the colliding names')
|
|
1631
|
+
assert.match(source, /'data-tree-batch-copy': '1'/, '生成副本 suffixes the colliding names')
|
|
1632
|
+
assert.match(source, /async function resolveBatchConflict\(policy\)/)
|
|
1633
|
+
assert.match(source, /await fsMoveEntry\(scope, item\.path, pending\.dir, leaf, true\)/, '覆盖 keeps the cut semantics for a drag')
|
|
1634
|
+
assert.match(source, /var placed = await pasteEntryInto\(item, pending\.dir, pending\.mode, false\)/, '生成副本 reuses the suffix rule')
|
|
1635
|
+
assert.doesNotMatch(source, /生成副本'\n\s*: null/)
|
|
1636
|
+
// One compound undo entry per batch.
|
|
1637
|
+
assert.match(source, /rememberUndo\(mode === 'cut' \? '移动 ' \+ created\.length \+ ' 项' : '粘贴 ' \+ created\.length \+ ' 项'/)
|
|
1638
|
+
// Batch delete: trash + one undo + multi-row confirm.
|
|
1639
|
+
assert.match(source, /async function removeEntries\(entries\)/)
|
|
1640
|
+
assert.match(source, /var items = Array\.isArray\(pendingDelete\) \? pendingDelete : \[pendingDelete\]/)
|
|
1641
|
+
// A batch is invisible while it happens: the tree must say how many rows are
|
|
1642
|
+
// selected, Esc must drop the batch, and vanished paths must leave it.
|
|
1643
|
+
assert.match(source, /'data-tree-selection': String\(selectedPaths\.length\)/)
|
|
1644
|
+
assert.match(source, /已选 ' \+ selectedPaths\.length \+ ' 项'/)
|
|
1645
|
+
assert.match(source, /if \(event\.key === 'Escape' && selectedPaths\.length > 1\)/)
|
|
1646
|
+
assert.match(source, /var alive = selectedPaths\.filter\(function \(path\) \{ return findEntry\(path\) !== undefined \}\)/)
|
|
1647
|
+
})
|
|
1648
|
+
|
|
1649
|
+
test('destructive file operations offer an inline undo and never strand focus', async () => {
|
|
1650
|
+
const { readFile } = await import('node:fs/promises')
|
|
1651
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
1652
|
+
// The toast itself carries 撤销: remembering Ctrl+Z is not a user interface.
|
|
1653
|
+
assert.match(source, /function notifyWithAction\(message, action\)/)
|
|
1654
|
+
assert.match(source, /'data-toast-action': String\(toast\.id\)/)
|
|
1655
|
+
assert.match(source, /function undoAction\(title\)/)
|
|
1656
|
+
// The tree hands its note callback down so delete/paste can pass the action.
|
|
1657
|
+
assert.match(source, /onActionNote: note/)
|
|
1658
|
+
// The delete dialog takes focus, answers Esc and gives focus back to the tree
|
|
1659
|
+
// (otherwise Del / the promised Ctrl+Z are dead right after a delete).
|
|
1660
|
+
assert.match(source, /var confirmCancelRef = useRef\(null\)/)
|
|
1661
|
+
assert.match(source, /function focusTreeRoot\(\)/)
|
|
1662
|
+
assert.match(source, /'data-tree-confirm-cancel': '1'/)
|
|
1354
1663
|
})
|
|
1355
1664
|
|
|
1356
1665
|
test('the recent-file dropdown is walkable like the result list', async () => {
|
|
@@ -1434,9 +1743,9 @@ test('the tree watch only reloads loaded directories and keeps a short cache', (
|
|
|
1434
1743
|
})
|
|
1435
1744
|
|
|
1436
1745
|
test('deletes park in the undo trash under a unique, recognisable name', () => {
|
|
1437
|
-
assert.equal(T.TREE_TRASH_DIR, '.dsh-ris-ide
|
|
1438
|
-
assert.equal(T.trashDirFor('/w/ris'), '/w/ris/.dsh-ris-ide
|
|
1439
|
-
assert.equal(T.trashDirFor('/w/ris/'), '/w/ris/.dsh-ris-ide
|
|
1746
|
+
assert.equal(T.TREE_TRASH_DIR, '.dsh-ris-ide/trash')
|
|
1747
|
+
assert.equal(T.trashDirFor('/w/ris'), '/w/ris/.dsh-ris-ide/trash')
|
|
1748
|
+
assert.equal(T.trashDirFor('/w/ris/'), '/w/ris/.dsh-ris-ide/trash')
|
|
1440
1749
|
assert.equal(T.trashNameFor('/w/ris/src/ModelHelper.java', 1730), '1730-ModelHelper.java')
|
|
1441
1750
|
assert.equal(T.trashNameFor('/w/ris/src', 1730), '1730-src')
|
|
1442
1751
|
})
|
|
@@ -1710,12 +2019,16 @@ test('the source tab bar scrolls its inner strip from anywhere on the row', () =
|
|
|
1710
2019
|
detach()
|
|
1711
2020
|
})
|
|
1712
2021
|
|
|
1713
|
-
test('the
|
|
2022
|
+
test('the title-bar controls share one 20px row height', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
1714
2023
|
const markup = renderWorkbench({ onConfig: { open() {}, generate() {}, exists: true } })
|
|
1715
|
-
const
|
|
1716
|
-
const
|
|
1717
|
-
|
|
1718
|
-
|
|
2024
|
+
const sourceHead = headOf(markup)
|
|
2025
|
+
const consoleHead = consoleHeadOf(markup)
|
|
2026
|
+
const buttonsOf = (head) => (head.match(/<button[^>]*>/g) || []).filter((tag) => /data-action="/.test(tag))
|
|
2027
|
+
const sourceTags = buttonsOf(sourceHead)
|
|
2028
|
+
const consoleTags = buttonsOf(consoleHead)
|
|
2029
|
+
assert.ok(sourceTags.length >= 3, 'the source toolbar carries the font scale, the theme switch and reset')
|
|
2030
|
+
assert.equal(consoleTags.length, 2, 'the console title bar carries 📄 open-config and ⚙ config-generate')
|
|
2031
|
+
for (const tag of sourceTags.concat(consoleTags)) {
|
|
1719
2032
|
const action = /data-action="([^"]+)"/.exec(tag)[1]
|
|
1720
2033
|
assert.match(tag, /height:20px/, `${action} must sit on the shared 20px row`)
|
|
1721
2034
|
assert.match(tag, /min-height:20px/, `${action} must pin the minimum too`)
|
|
@@ -1822,9 +2135,80 @@ test('Ctrl+F goes to the workspace search unless the editor owns it', () => {
|
|
|
1822
2135
|
assert.equal(T.globalFindShouldFocusSearch({ tagName: 'DIV', defaultPrevented: true }), false, 'editor already handled it')
|
|
1823
2136
|
})
|
|
1824
2137
|
|
|
2138
|
+
test('a whole workbench console row picks the program, name and blank alike', async () => {
|
|
2139
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2140
|
+
// The row div itself is the hit target (the name span and the blank stretch
|
|
2141
|
+
// before the run buttons both land here); run controls stop the bubble so
|
|
2142
|
+
// pressing ■ on another program does not also switch this pane's log.
|
|
2143
|
+
assert.match(source, /onClick: function \(\) \{ selectProgram\(program\) \}/, 'row picks the program')
|
|
2144
|
+
assert.match(source, /button\('▶', function \(event\) \{ event\.stopPropagation\(\); void consoleStart\(program\) \}/)
|
|
2145
|
+
assert.match(source, /button\(stopGlyph\(11\), function \(event\) \{ event\.stopPropagation\(\); void consoleStop\(program\) \}/)
|
|
2146
|
+
assert.match(source, /button\('⟳', function \(event\) \{ event\.stopPropagation\(\); void consoleRestart\(program\) \}/)
|
|
2147
|
+
assert.match(source, /button\(ideBadgeIcon\('bug', 'play', 13\), function \(event\) \{ event\.stopPropagation\(\); void consoleDebug\(program\) \}/)
|
|
2148
|
+
})
|
|
2149
|
+
|
|
2150
|
+
test('sidebar start/stop/restart stay silent, and ⟳ is green like ▶', async () => {
|
|
2151
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2152
|
+
// The sidebar row itself shows the settled state (dot + ▶/■ swap): successes
|
|
2153
|
+
// must not push the list down with a "已启动" strip. Failures still do.
|
|
2154
|
+
assert.doesNotMatch(source, /program\.name \+ ' 已(启动|重启|停止)'/, 'no success note in the sidebar console')
|
|
2155
|
+
assert.doesNotMatch(source, /program\.name \+ ' 已在运行'/, 'already-running stays silent too')
|
|
2156
|
+
assert.match(source, /'启动失败:' : kind === 'restart' \? '重启失败:' : '停止失败:'/, 'failures still surface')
|
|
2157
|
+
// ⟳ (re)starts, so it shares ▶'s green in BOTH consoles; ■ keeps red.
|
|
2158
|
+
assert.match(source, /S\.startIcon, disabled: busy, 'data-action': 'restart'/, 'sidebar ⟳ is green')
|
|
2159
|
+
assert.match(source, /width: 25, start: true, action: 'console-restart'/, 'workbench ⟳ is green')
|
|
2160
|
+
})
|
|
2161
|
+
|
|
2162
|
+
test('the stop mark is a drawn square, and the sidebar batch bar keeps the row tones', async () => {
|
|
2163
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2164
|
+
// The ■ character's ink is about half its advance width: inside a 20px sidebar
|
|
2165
|
+
// button (or a 25px workbench one) it read as a dot. Every stop control draws a
|
|
2166
|
+
// fixed square instead, so both consoles agree on the size.
|
|
2167
|
+
// Module scope, not inside ProgramWorkbench: the sidebar ProgramsPanel draws it too,
|
|
2168
|
+
// and a nested declaration makes the whole sidebar tab throw "stopGlyph is not defined".
|
|
2169
|
+
assert.match(source, /^ {4}function stopGlyph\(size\) \{/m, 'stopGlyph is declared at module scope')
|
|
2170
|
+
assert.match(source, /width: side, height: side, flex: '0 0 auto'/, 'the square has a real box')
|
|
2171
|
+
assert.match(
|
|
2172
|
+
source,
|
|
2173
|
+
/display: 'inline-block', verticalAlign: 'middle'/,
|
|
2174
|
+
'the square keeps the text line box, so the border matches the neighbouring buttons',
|
|
2175
|
+
)
|
|
2176
|
+
assert.match(source, /S\.paneIconOff : S\.stopIcon, 'data-action': 'batch-stop'/, 'sidebar batch ■ is red like the row ■')
|
|
2177
|
+
assert.match(source, /S\.paneIconOff : S\.startIcon, 'data-action': 'batch-start'/, 'sidebar batch ▶ is green like the row ▶')
|
|
2178
|
+
assert.match(source, /width: 25, stop: true, action: 'batch-stop'/, 'workbench batch ■ keeps its red tone')
|
|
2179
|
+
const glyphUses = source.match(/stopGlyph\(/g) || []
|
|
2180
|
+
assert.ok(glyphUses.length >= 4, 'both consoles (row + batch) draw the square')
|
|
2181
|
+
})
|
|
2182
|
+
|
|
2183
|
+
test('copying in the tree also publishes the files to the OS clipboard', async () => {
|
|
2184
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2185
|
+
// The internal clipboard alone only feeds the tree's own Ctrl+V. Putting the
|
|
2186
|
+
// SAME list on the system clipboard is what lets Explorer / a desktop paste it;
|
|
2187
|
+
// the page cannot do that itself, so the Host route does it — and when the Host
|
|
2188
|
+
// has no backend the paths still land as text instead of the copy failing.
|
|
2189
|
+
assert.match(source, /dsh-ris-ide\/clipboard\/files/, 'the copy asks the host clipboard route')
|
|
2190
|
+
assert.match(source, /await fsClipboardFiles\(scope, items, mode === 'cut'\)/, 'cut keeps its MOVE intent')
|
|
2191
|
+
assert.match(source, /function clipboardQuery\(scope\) \{/, 'the host needs the workspace to stage a copy')
|
|
2192
|
+
assert.match(source, /await fsClipboardFiles\(scope, items, mode === 'cut'\)[\s\S]{0,40}/)
|
|
2193
|
+
assert.match(source, /await navigator\.clipboard\.writeText\(items\.map/, 'without a backend the paths still land as text')
|
|
2194
|
+
assert.match(source, /void publishSystemClipboard\(items, mode\)/, 'beginCopy publishes right after it sets the internal clipboard')
|
|
2195
|
+
})
|
|
2196
|
+
|
|
2197
|
+
test('console program rows keep one horizontal inset when a row is picked', async () => {
|
|
2198
|
+
const S = T.stylesFor(1)
|
|
2199
|
+
assert.equal(S.consoleRow.padding, '1px 6px', 'unpicked rows have a left/right inset')
|
|
2200
|
+
assert.equal(S.consoleRowOn.padding, S.consoleRow.padding, 'picking must not change the padding')
|
|
2201
|
+
assert.equal(S.consoleRowOn.boxShadow, undefined, 'the picked row adds no border/shadow')
|
|
2202
|
+
// Both consoles (standalone workbench and the sidebar) render with these two
|
|
2203
|
+
// styles: the picked/unpicked swap must not touch padding either.
|
|
2204
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2205
|
+
assert.match(source, /selected \? S\.consoleRowOn : S\.consoleRow/, 'workbench console rows use both styles')
|
|
2206
|
+
assert.match(source, /picked \? S\.consoleRowOn : S\.consoleRow/, 'sidebar console rows use both styles')
|
|
2207
|
+
})
|
|
2208
|
+
|
|
1825
2209
|
test('the help panel data covers tree, editor and debug shortcuts', () => {
|
|
1826
2210
|
const sections = T.helpSections()
|
|
1827
|
-
assert.deepEqual(sections.map((section) => section.title), ['通用', '文件树', '编辑器', '调试(仅 Java)', '使用说明'])
|
|
2211
|
+
assert.deepEqual(sections.map((section) => section.title), ['通用', '文件树', '检索', '编辑器', '日志', '配置', '调试(仅 Java)', '使用说明'])
|
|
1828
2212
|
for (const section of sections) {
|
|
1829
2213
|
assert.ok(section.rows.length > 0, `${section.title} has rows`)
|
|
1830
2214
|
for (const row of section.rows) {
|
|
@@ -1835,9 +2219,31 @@ test('the help panel data covers tree, editor and debug shortcuts', () => {
|
|
|
1835
2219
|
}
|
|
1836
2220
|
const treeKeys = sections.find((section) => section.title === '文件树').rows.map((row) => row.keys).join(' ')
|
|
1837
2221
|
assert.match(treeKeys, /Ctrl\+Z/, 'tree undo is documented')
|
|
2222
|
+
const searchKeys = sections.find((section) => section.title === '检索').rows.map((row) => row.keys).join(' ')
|
|
2223
|
+
assert.match(searchKeys, /↑ \/ ↓/, 'the results dropdown is keyboard-navigable')
|
|
2224
|
+
assert.match(searchKeys, /Enter/, 'Enter opens the highlighted result')
|
|
2225
|
+
const editorShortcutKeys = sections.find((section) => section.title === '编辑器').rows.map((row) => row.keys).join(' ')
|
|
2226
|
+
assert.match(editorShortcutKeys, /运行测试/, 'the per-file test run is documented')
|
|
2227
|
+
assert.match(editorShortcutKeys, /±/, 'the saved-vs-buffer diff is documented')
|
|
2228
|
+
const logShortcutKeys = sections.find((section) => section.title === '日志').rows.map((row) => row.keys).join(' ')
|
|
2229
|
+
assert.match(logShortcutKeys, /W\+/, 'the log level filter is documented')
|
|
2230
|
+
// Ctrl+W / Ctrl+F4 are browser-reserved: a page cannot cancel them, so the
|
|
2231
|
+
// help panel must not promise them as working shortcuts.
|
|
2232
|
+
const generalRows = sections.find((section) => section.title === '通用').rows
|
|
2233
|
+
const generalKeys = generalRows.map((row) => row.keys).join(' ')
|
|
2234
|
+
assert.doesNotMatch(generalKeys, /Ctrl\+W/, 'the browser-reserved Ctrl+W is not documented')
|
|
2235
|
+
assert.doesNotMatch(generalKeys, /Ctrl\+F4/, 'nor Ctrl+F4')
|
|
2236
|
+
assert.match(generalKeys, /Alt\+W/, 'the reachable close-tab chord is documented instead')
|
|
2237
|
+
assert.doesNotMatch(generalKeys, /Ctrl\+Alt\+W/, 'only Alt+W is advertised (user口径)')
|
|
1838
2238
|
const editorKeys = sections.find((section) => section.title === '编辑器').rows.map((row) => row.keys).join(' ')
|
|
1839
2239
|
assert.match(editorKeys, /Ctrl\+Shift\+K/)
|
|
1840
|
-
|
|
2240
|
+
// README documented log Ctrl+F but the help panel never did (PM P1-5).
|
|
2241
|
+
const logKeys = sections.find((section) => section.title === '日志').rows.map((row) => row.keys).join(' ')
|
|
2242
|
+
assert.match(logKeys, /Ctrl\+F/, 'log find is documented')
|
|
2243
|
+
const configKeys = sections.find((section) => section.title === '配置').rows.map((row) => row.keys).join(' ')
|
|
2244
|
+
assert.match(configKeys, /\.dsh-ris-ide\/config\.json/, 'the config file (inside the state folder) is documented')
|
|
2245
|
+
// The help panel must not promise an editor back/forward that does not exist.
|
|
2246
|
+
assert.doesNotMatch(generalKeys, /Alt\+\u2190/, 'no fake editor back/forward row')
|
|
1841
2247
|
})
|
|
1842
2248
|
|
|
1843
2249
|
test('the workbench renders the bottom-right help button', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
@@ -1856,6 +2262,41 @@ test('the tree title bar carries the refresh button and the .gitignore eye', { s
|
|
|
1856
2262
|
assert.match(filterMarkup, /data-icon="eye"/, 'an eye (not a funnel/triangle) reads as visibility')
|
|
1857
2263
|
})
|
|
1858
2264
|
|
|
2265
|
+
test('the log find bar matches the editor find panel: chips and a tabular counter', async () => {
|
|
2266
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2267
|
+
const start = source.indexOf('data-log-find-bar')
|
|
2268
|
+
const region = source.slice(start - 400, start + 2600)
|
|
2269
|
+
assert.match(source, /logFindBar: \{/, 'the bar has its own style')
|
|
2270
|
+
assert.match(source, /logFindChip: \{/, 'arrows/close share one chip style')
|
|
2271
|
+
assert.match(source, /logFindCount: \{ fontSize: 11, opacity: 0\.62/, 'the counter mirrors the editor panel')
|
|
2272
|
+
assert.match(region, /style: S\.logFindBar, 'data-log-find-bar': '1'/)
|
|
2273
|
+
assert.match(region, /style: S\.logFindChip, 'data-action': 'log-find-prev'/, 'prev is a chip, not a padded button')
|
|
2274
|
+
assert.match(region, /style: S\.logFindChip, 'data-action': 'log-find-close'/, 'close is a chip too')
|
|
2275
|
+
assert.doesNotMatch(region, /padding: '0 4px' \}\), 'data-action': 'log-find-close'/, 'no ad-hoc padded close button')
|
|
2276
|
+
})
|
|
2277
|
+
|
|
2278
|
+
test('a background tree refresh stays silent; only the title bar refresh confirms', async () => {
|
|
2279
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2280
|
+
assert.match(source, /async function refreshTree\(announce\)/, 'refresh takes a "the user asked" flag')
|
|
2281
|
+
assert.match(source, /if \(announce !== true\) return\n\s*notify\(failed === 0/, 'silent unless announced')
|
|
2282
|
+
assert.match(source, /void refreshTree\(props\.refreshAnnounce === true\)/, 'the effect forwards the flag')
|
|
2283
|
+
assert.match(source, /var \[treeRefresh, setTreeRefresh\] = useState\(\{ tick: 0, announce: false \}\)/, 'tick and announce travel together')
|
|
2284
|
+
assert.match(source, /announce: false \} \}\)\n\s*note\(next \? '文件树:显示所有文件/, 'the filter toggle stays silent')
|
|
2285
|
+
assert.match(source, /announce: true \} \}\)/, 'the title bar asks for a toast')
|
|
2286
|
+
assert.match(source, /refreshNonce: treeRefresh\.tick, refreshAnnounce: treeRefresh\.announce/, 'both reach IdeTree')
|
|
2287
|
+
})
|
|
2288
|
+
|
|
2289
|
+
test('the large-file preview keeps its own component identity and remembers its offset', async () => {
|
|
2290
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
2291
|
+
const previewAt = source.indexOf('function LargeTextPreview(props) {')
|
|
2292
|
+
const workbenchAt = source.indexOf('function ProgramWorkbench(props) {')
|
|
2293
|
+
assert.ok(previewAt !== -1 && previewAt < workbenchAt, 'LargeTextPreview is module scope, not nested in ProgramWorkbench')
|
|
2294
|
+
assert.match(source, /var LARGE_TEXT_VIEW = new Map\(\)/, 'scroll offsets are remembered per path')
|
|
2295
|
+
assert.match(source, /LARGE_TEXT_VIEW\.set\(props\.path, box\.scrollTop\)/, 'scrolling records the offset')
|
|
2296
|
+
assert.match(source, /props\.active === false\) return/, 'a hidden pane is not restored')
|
|
2297
|
+
assert.match(source, /doc: doc, path: path, active: active,/, 'the pane passes path/active')
|
|
2298
|
+
})
|
|
2299
|
+
|
|
1859
2300
|
test('the tree .gitignore eye fetches unfiltered listings, then re-reads the tree', async () => {
|
|
1860
2301
|
const { readFile } = await import('node:fs/promises')
|
|
1861
2302
|
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
@@ -1863,7 +2304,7 @@ test('the tree .gitignore eye fetches unfiltered listings, then re-reads the tre
|
|
|
1863
2304
|
assert.match(source, /if \(TREE_FILTER_ALL\) url\.searchParams\.set\('filter', 'all'\)/, 'the toggle reaches the host')
|
|
1864
2305
|
assert.match(source, /\(TREE_FILTER_ALL \? '\\u0000all' : ''\)/, 'the cache key folds in the mode')
|
|
1865
2306
|
assert.match(source, /function toggleTreeFilter\(\) \{/)
|
|
1866
|
-
assert.match(source, /
|
|
2307
|
+
assert.match(source, /setTreeRefresh\(function \(value\) \{ return \{ tick: value\.tick \+ 1, announce: false \} \}\)/, 'a flip reloads root + expanded folders, silently')
|
|
1867
2308
|
assert.match(source, /data-filter-state': treeShowAll === true \? 'all' : 'git'/)
|
|
1868
2309
|
assert.match(source, /ideIcon\(treeShowAll === true \? 'eyeOff' : 'eye', 14\)/, 'eye-off = ignored files shown too')
|
|
1869
2310
|
assert.match(source, /disabled: treeGit !== true/, 'no git → nothing to filter')
|
|
@@ -1985,7 +2426,7 @@ test('Ctrl+R turns a single-line editor selection into the search query', async
|
|
|
1985
2426
|
assert.match(source, /if \(text === '' \|\| text\.indexOf\('\\n'\) !== -1 \|\| text\.length > GLOBAL_FIND_SELECTION_MAX\) return ''/, 'multiline / oversized selections are ignored')
|
|
1986
2427
|
assert.match(source, /if \(element\.closest\('\.cm-content'\) === null\) return ''/, 'only editor selections count')
|
|
1987
2428
|
assert.match(source, /var picked = selectedEditorText\(\)[\s\S]{0,400}?setTreeQuery\(picked\)/, 'the pick becomes the query')
|
|
1988
|
-
assert.match(source, /h\(SearchResults, \{[\s\S]{0,
|
|
2429
|
+
assert.match(source, /h\(SearchResults, \{[\s\S]{0,600}?active: searchActive, onHover: setSearchActive,[\s\S]{0,120}?fontRatio: fontRatio, cwd: cwd,/, 'results know the workspace root and the highlighted row')
|
|
1989
2430
|
})
|
|
1990
2431
|
|
|
1991
2432
|
test('an unfocused editor stops painting its selection', async () => {
|
|
@@ -2556,7 +2997,7 @@ test('every breakpoint row deletes from the LEFT, pre-set breakpoints included',
|
|
|
2556
2997
|
assert.match(source, /width: 20, minWidth: 20, height: 20, padding: '0 0'/, 'the row delete is a 20px square icon button')
|
|
2557
2998
|
assert.equal(source.split("'data-bp-remove': '1'").length - 1, 2, 'one shared + one failed-row icon button')
|
|
2558
2999
|
const breakpointRows = source.slice(source.indexOf('var rows = []'), source.indexOf("} else if (ui.section === 'threads')"))
|
|
2559
|
-
assert.
|
|
3000
|
+
assert.ok(breakpointRows.split("}, '×')").length - 1 >= 2, 'both buttons render the × glyph, no text label')
|
|
2560
3001
|
})
|
|
2561
3002
|
|
|
2562
3003
|
test('the breakpoint clear-all is a title-bar icon, not an in-body text button', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
@@ -2595,6 +3036,18 @@ function headOf(markup) {
|
|
|
2595
3036
|
return markup.slice(start, end)
|
|
2596
3037
|
}
|
|
2597
3038
|
|
|
3039
|
+
/**
|
|
3040
|
+
* The CONSOLE pane's title bar: from its marker up to the source pane's title
|
|
3041
|
+
* bar (the grid renders the left column first, so the console header is what
|
|
3042
|
+
* sits between them).
|
|
3043
|
+
*/
|
|
3044
|
+
function consoleHeadOf(markup) {
|
|
3045
|
+
const start = markup.indexOf('data-console-head="1"')
|
|
3046
|
+
assert.ok(start !== -1, 'the console pane must render its own title bar')
|
|
3047
|
+
const end = markup.indexOf('data-editor-head="1"', start)
|
|
3048
|
+
return markup.slice(start, end === -1 ? undefined : end)
|
|
3049
|
+
}
|
|
3050
|
+
|
|
2598
3051
|
/**
|
|
2599
3052
|
* SSR the workbench with a file already open (via the saved-UI localStorage the
|
|
2600
3053
|
* workbench reads on mount) — the toolbar is rendered from that state, so a
|
|
@@ -2676,10 +3129,11 @@ test('the IDE grid has four draggable splitters and applies the default pane siz
|
|
|
2676
3129
|
})
|
|
2677
3130
|
|
|
2678
3131
|
test('the IDE top bar hosts the workspace search and only shows config buttons when hosted', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
2679
|
-
const
|
|
3132
|
+
const markup = renderWorkbench({ onConfig: { open() {}, generate() {}, exists: true } })
|
|
3133
|
+
const head = headOf(markup)
|
|
2680
3134
|
assert.match(head, /data-action="tree-search"/, 'the tree search input sits in the top bar')
|
|
2681
|
-
assert.
|
|
2682
|
-
assert.
|
|
3135
|
+
assert.doesNotMatch(head, /data-action="config-open"/, 'the config buttons left the source pane toolbar')
|
|
3136
|
+
assert.doesNotMatch(head, /data-action="config-generate"/)
|
|
2683
3137
|
|
|
2684
3138
|
const bare = headOf(renderWorkbench({}))
|
|
2685
3139
|
assert.match(bare, /data-action="tree-search"/, 'the search belongs to the top bar itself')
|
|
@@ -2697,12 +3151,18 @@ test('the IDE top bar hosts the workspace search and only shows config buttons w
|
|
|
2697
3151
|
assert.match(resetTag[0], /width:22px/, 'the restore-layout control is an icon button')
|
|
2698
3152
|
assert.match(resetTag[0], /text-align:center/)
|
|
2699
3153
|
}
|
|
2700
|
-
// The config controls are icon buttons
|
|
3154
|
+
// The config controls are icon buttons in the CONSOLE title bar: they describe
|
|
3155
|
+
// the programs listed underneath (the sidebar console keeps 打开配置/更新配置
|
|
3156
|
+
// in the same place), so they no longer ride on the source pane toolbar.
|
|
3157
|
+
const consoleHead = consoleHeadOf(markup)
|
|
3158
|
+
assert.match(consoleHead, /title="打开配置文件/, 'the console offers 📄 for .dsh-ris-ide/config.json')
|
|
2701
3159
|
for (const action of ['config-open', 'config-generate']) {
|
|
2702
|
-
const tag =
|
|
2703
|
-
assert.ok(tag !== null, `missing ${action}`)
|
|
3160
|
+
const tag = consoleHead.match(new RegExp(`<button[^>]*data-action="${action}"[^>]*>`))
|
|
3161
|
+
assert.ok(tag !== null, `missing ${action} in the console title bar`)
|
|
2704
3162
|
assert.match(tag[0], /width:22px/)
|
|
2705
3163
|
}
|
|
3164
|
+
// Without a host callback the console renders neither button.
|
|
3165
|
+
assert.doesNotMatch(renderWorkbench({}), /data-action="config-open"/)
|
|
2706
3166
|
})
|
|
2707
3167
|
|
|
2708
3168
|
test('debug controls live in the debug pane toolbar, not in the top bar', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
@@ -3237,7 +3697,17 @@ test('one IDE window per workspace: the window name is keyed by the workspace cw
|
|
|
3237
3697
|
assert.match(source, /var windowCwd = typeof opts\.windowCwd === 'string'/)
|
|
3238
3698
|
assert.match(source, /var windowName = standaloneWindowName\(windowCwd !== undefined \? windowCwd : cwd\)/)
|
|
3239
3699
|
assert.match(source, /url\.searchParams\.set\('wname', windowName\)/)
|
|
3240
|
-
|
|
3700
|
+
// A workspace owns ONE window: ask the host registry first, and only create a
|
|
3701
|
+
// window when the registry says there is none (no blank popup that is closed
|
|
3702
|
+
// again, which both flashes and still fails to raise the window).
|
|
3703
|
+
assert.match(source, /async function openStandaloneWindow\(options\) \{/)
|
|
3704
|
+
assert.match(source, /if \(state\.exists === true && state\.alive === true\) \{/)
|
|
3705
|
+
assert.doesNotMatch(source, /focusStandaloneWindow/, 'raising a foreign window is not attempted any more')
|
|
3706
|
+
assert.match(source, /await requestStandaloneWindowClose\(windowName\)/, 'present: ask the old window to close, then open one')
|
|
3707
|
+
assert.doesNotMatch(source, /focus-ack/, 'no focus handshake: the browser forbids it')
|
|
3708
|
+
assert.match(source, /window\.open\(url\.href, windowName, features\)/, 'absent: create it straight on the IDE url')
|
|
3709
|
+
assert.doesNotMatch(source, /window\.open\('', windowName, features\)/, 'never a blank window to close again')
|
|
3710
|
+
assert.doesNotMatch(source, /settleStandaloneWindow/)
|
|
3241
3711
|
})
|
|
3242
3712
|
|
|
3243
3713
|
test('the standalone window claims a single-instance lock before booting the IDE', async () => {
|
|
@@ -3252,7 +3722,11 @@ test('the standalone window claims a single-instance lock before booting the IDE
|
|
|
3252
3722
|
assert.match(claim, /BroadcastChannel/, 'fallback channel exists')
|
|
3253
3723
|
assert.match(claim, /params\.get\('wname'\)/, 'the opener hands the workspace window name over')
|
|
3254
3724
|
assert.match(claim, /var key = windowName/, 'the lock key IS the window name')
|
|
3255
|
-
assert.match(claim, /type
|
|
3725
|
+
assert.match(claim, /data\.type === 'focus'/, 'the surviving window is nudged forward')
|
|
3726
|
+
assert.match(claim, /data\.type === 'close'/, 'the opener can ask the old window to close itself')
|
|
3727
|
+
assert.match(claim, /function closeForOpener\(\)/, 'closing is the window\'s own decision')
|
|
3728
|
+
assert.match(claim, /function takeover\(\)/, 'the blocked window can wait for the old lock and boot here')
|
|
3729
|
+
assert.match(claim, /关闭旧窗口,在这里打开/, 'the duplicate offers to replace the old window')
|
|
3256
3730
|
// A reused window (same name, e.g. after a dsh restart) can still see the old
|
|
3257
3731
|
// document's lock for a moment: retry before believing there is a real second
|
|
3258
3732
|
// window, and NEVER close this one (that made it flash and vanish).
|
|
@@ -3262,7 +3736,7 @@ test('the standalone window claims a single-instance lock before booting the IDE
|
|
|
3262
3736
|
// offers an explicit "close this window" action instead — and only that button
|
|
3263
3737
|
// may close it (never an automatic close at boot).
|
|
3264
3738
|
assert.match(claim, /关闭这个窗口/, 'the duplicate window can be closed on demand')
|
|
3265
|
-
assert.equal((claim.match(/window\.close\(\)/g) || []).length,
|
|
3739
|
+
assert.equal((claim.match(/window\.close\(\)/g) || []).length, 2, 'closing happens only from the two explicit user actions')
|
|
3266
3740
|
// Booting waits for the claim, so the notice cannot be raced by a mounted panel.
|
|
3267
3741
|
assert.match(html, /window\.__risIdeClaimReady/)
|
|
3268
3742
|
assert.match(html, /window\.__risIdeBootPanel = bootPanel/)
|
|
@@ -3378,8 +3852,8 @@ test('a render failure inside the panel shows a retry banner instead of taking d
|
|
|
3378
3852
|
assert.equal(typeof T.IdeErrorBoundary, 'function')
|
|
3379
3853
|
|
|
3380
3854
|
// BOTH mount points are wrapped (the dsh sidebar tab and the standalone window).
|
|
3381
|
-
assert.match(source, /function IdePanelBoundary\(props\) \{ return h\(IdeErrorBoundary, null, h\(ProgramsPanel, props\)\) \}/)
|
|
3382
|
-
assert.match(source, /root\.render\(h\(IdeErrorBoundary, null, h\(
|
|
3855
|
+
assert.match(source, /function IdePanelBoundary\(props\) \{ return h\(IdeErrorBoundary, null, h\(ProgramsPanel, Object\.assign\(\{\}, props, \{ clientCtx: ctx \}\)\)\) \}/)
|
|
3856
|
+
assert.match(source, /root\.render\(h\(IdeErrorBoundary, null, h\(StandaloneWindow, \{ sessionId: sessionId, cwd: cwd \}\)\)\)/)
|
|
3383
3857
|
})
|
|
3384
3858
|
|
|
3385
3859
|
test('a start switches to that program log before waiting for the spawn', async () => {
|
|
@@ -3390,7 +3864,7 @@ test('a start switches to that program log before waiting for the spawn', async
|
|
|
3390
3864
|
// block for START_WAIT_MS, and Maven compile prints nothing for tens of seconds.
|
|
3391
3865
|
assert.match(source, /async function consoleStart\(program\) \{\n\s*\/\/[\s\S]*?\n\s*selectProgram\(program\)[\s\S]*?setConsoleBusy\(program\.id\)[\s\S]*?requestStart\(program\.id, scopeRef\.current\)/)
|
|
3392
3866
|
// The sidebar rows do the same before awaiting requestStart.
|
|
3393
|
-
assert.match(source, /if \(
|
|
3867
|
+
assert.match(source, /if \(boots\) \{ setActive\(program\); broadcastLogFocus\(program\.logPath\); setCompactLogNonce/)
|
|
3394
3868
|
// …and every window watching another log is moved by the same broadcast.
|
|
3395
3869
|
assert.match(source, /function broadcastLogFocus\(logPath\)/)
|
|
3396
3870
|
})
|
|
@@ -3407,7 +3881,7 @@ test('the debug pane has a visual settings dialog for dependency sources', { ski
|
|
|
3407
3881
|
assert.match(source, /fsDependencySource\(scopeRef\.current, cleaned/, 'a missing workspace source asks the host for the jar source')
|
|
3408
3882
|
assert.match(source, /dsh-ris-ide\/debug\/source/)
|
|
3409
3883
|
assert.match(source, /-sources\.jar/)
|
|
3410
|
-
assert.match(source, /\.dsh-ris-ide
|
|
3884
|
+
assert.match(source, /\.dsh-ris-ide\/cache/)
|
|
3411
3885
|
})
|
|
3412
3886
|
|
|
3413
3887
|
test('the IDE console masks a program row while it starts, stops or debugs, and the compact note expires', async () => {
|
|
@@ -3419,7 +3893,7 @@ test('the IDE console masks a program row while it starts, stops or debugs, and
|
|
|
3419
3893
|
assert.match(source, /setConsoleBusy\(program\.id\)/)
|
|
3420
3894
|
assert.match(source, /data-program-loading': program\.id/)
|
|
3421
3895
|
// The mask is the same overlay the compact console uses, on a positioned row.
|
|
3422
|
-
assert.match(source, /position: 'relative', overflow: 'hidden' \}\),\n\s*'data-console-on'/)
|
|
3896
|
+
assert.match(source, /position: 'relative', overflow: 'hidden', cursor: 'pointer',\n\s*\}\),\n\s*'data-console-on'/)
|
|
3423
3897
|
assert.match(source, /PROGRAM_LOADING_CSS/)
|
|
3424
3898
|
// A transient top-bar note clears itself after 5 seconds.
|
|
3425
3899
|
assert.match(source, /\}, 5000\)\n\s*return function \(\) \{ clearTimeout\(timer\) \}/)
|
|
@@ -3431,7 +3905,12 @@ test('the console row masks itself while a start/stop is in flight', async () =>
|
|
|
3431
3905
|
assert.match(source, /'data-program-loading': program\.id/)
|
|
3432
3906
|
assert.match(source, /className: 'dsh-ris-ide-loading'/)
|
|
3433
3907
|
assert.match(source, /dshRisIdeSpin/)
|
|
3434
|
-
|
|
3908
|
+
// The label follows the ACTION, not `alive`: debugging a running program used
|
|
3909
|
+
// to flash 停止中 because the host restarts it in place.
|
|
3910
|
+
assert.match(source, /function busyMaskText\(alive, kind\) \{/)
|
|
3911
|
+
assert.match(source, /'data-program-loading-kind': busyKind/)
|
|
3912
|
+
assert.match(source, /'data-program-loading-kind': consoleBusyKind/)
|
|
3913
|
+
assert.doesNotMatch(source, /alive \? '停止中…' : '启动中…'/)
|
|
3435
3914
|
// The mask swallows the click, and the row is the containing block for it.
|
|
3436
3915
|
assert.match(source, /onClick: function \(event\) \{ event\.stopPropagation\(\); event\.preventDefault\(\) \}/)
|
|
3437
3916
|
assert.match(source, /position: 'relative', overflow: 'hidden'/)
|
|
@@ -3642,6 +4121,16 @@ test('Ctrl+F searches what the editor, log or fallback editor has highlighted',
|
|
|
3642
4121
|
assert.match(chunk, /search: picked/)
|
|
3643
4122
|
const seeded = chunk.split('searchSelectedText(instance);').length - 1
|
|
3644
4123
|
assert.ok(seeded >= 2, 'both the menu item and the Mod-f keymap seed the query from the selection')
|
|
4124
|
+
// Automatic searches start at the file top: the first occurrence wins, not the
|
|
4125
|
+
// next one after a caret parked deep in the document.
|
|
4126
|
+
assert.match(chunkSource, /function findFirstFromStart\(view\) \{\n\s*view\.dispatch\(\{ selection: \{ anchor: 0 \} \}\)\n\s*findNext\(view\)/)
|
|
4127
|
+
assert.match(chunkSource, /if \(jump\) findFirstFromStart\(view\)/)
|
|
4128
|
+
assert.match(chunkSource, /const seeded = searchSelectedText\(instance\); openSearchPanel\(instance\); if \(seeded\) findFirstFromStart\(instance\)/)
|
|
4129
|
+
assert.match(chunk, /function findFirstFromStart\(view\)/)
|
|
4130
|
+
assert.match(chunk, /if \(jump\) findFirstFromStart\(view\)/)
|
|
4131
|
+
// A handed-over hit still starts at ITS line (that is the point of clicking it).
|
|
4132
|
+
assert.match(chunkSource, /if \(typeof line === 'number' && Number\.isFinite\(line\) && line > 0\) \{/)
|
|
4133
|
+
assert.match(chunkSource, /No hit line to honour: an automatic search starts from the file's top/)
|
|
3645
4134
|
|
|
3646
4135
|
// Log viewer + plain-text fallback editor: their own find bars get the highlight.
|
|
3647
4136
|
assert.match(source, /function selectedLineTextIn\(element\)/)
|
|
@@ -3678,6 +4167,31 @@ test('an oversized text file opens a read-only windowed preview', async () => {
|
|
|
3678
4167
|
assert.match(source, /function reloadLargeTextFromStart\(path\)/)
|
|
3679
4168
|
assert.match(source, /'data-large-text-restart': '1'/)
|
|
3680
4169
|
assert.match(source, /已释放前面 ' \+ dropLines \+ ' 行/)
|
|
4170
|
+
// 回归:`loadLargeTextPage` 读 `docsRef`,而 too-large 分支里的 `setDocs` 还没提交,
|
|
4171
|
+
// 当场调用只会看到 undefined 然后静默返回(预览停在「已加载 0 KB」)。必须等提交。
|
|
4172
|
+
assert.match(source, /function startFirstPage\(attempt\) \{/)
|
|
4173
|
+
assert.match(source, /if \(current !== undefined && current\.kind === 'large-text'\) \{/)
|
|
4174
|
+
assert.match(source, /startFirstPage\(0\)/)
|
|
4175
|
+
// 首帧/未填满也必须拉下一页(否则没有滚动条,滚动事件永远不来)。
|
|
4176
|
+
assert.match(source, /if \(box\.scrollHeight <= box\.clientHeight \+ 240\) props\.onLoadMore\(\)/)
|
|
4177
|
+
assert.match(source, /\}, \[doc\.text, doc\.loading, doc\.eof, doc\.error, doc\.size\]\)/)
|
|
4178
|
+
// The preview's right end carries a 编辑 button that force-loads the whole file
|
|
4179
|
+
// and hands it to the normal editor (the preview buffer frees its front, so this
|
|
4180
|
+
// has to re-read the file; the path is remembered so reopening stays editable).
|
|
4181
|
+
assert.match(source, /'data-large-text-edit': '1'/)
|
|
4182
|
+
assert.match(source, /if \(typeof props\.onForceEdit === 'function'\) props\.onForceEdit\(\)/)
|
|
4183
|
+
assert.match(source, /onForceEdit: function \(\) \{ void forceEditLargeText\(path\) \}/)
|
|
4184
|
+
assert.match(source, /var LARGE_TEXT_FORCE_MAX_BYTES = 32 \* 1024 \* 1024/)
|
|
4185
|
+
assert.match(source, /async function readWholeFileText\(path\)/)
|
|
4186
|
+
assert.match(source, /if \(page\.eof === true \|\| typeof page\.next !== 'number' \|\| page\.next <= from\) break/)
|
|
4187
|
+
assert.match(source, /async function forceEditLargeText\(path\)/)
|
|
4188
|
+
assert.match(source, /forceEditPathsRef\.current\.add\(path\)/)
|
|
4189
|
+
assert.match(source, /next\[path\] = \{ kind: 'text', text: normalized, saved: normalized, eol: eol \}/)
|
|
4190
|
+
assert.match(source, /已全量加载并进入编辑:' \+ fileBaseName\(path\)/)
|
|
4191
|
+
assert.match(source, /不能强制全量编辑;右端按钮上限 /)
|
|
4192
|
+
// Reopening a forced path skips the preview and loads the whole thing again.
|
|
4193
|
+
assert.match(source, /if \(code === 'too-large' && forceEditPathsRef\.current\.has\(path\)\) \{/)
|
|
4194
|
+
assert.match(source, /setTimeout\(function \(\) \{ void forceEditLargeText\(path\) \}, 50\)/)
|
|
3681
4195
|
})
|
|
3682
4196
|
|
|
3683
4197
|
test('trimLargeTextFront frees whole lines and keeps the line count aligned', () => {
|
|
@@ -3699,7 +4213,10 @@ test('the editor scrollbars are visible and a start re-reads its log', async ()
|
|
|
3699
4213
|
assert.match(source, /var SCROLLBAR_CSS = /)
|
|
3700
4214
|
assert.match(source, /::-webkit-scrollbar\{width:10px;height:10px\}/)
|
|
3701
4215
|
assert.match(source, /::-webkit-scrollbar-thumb/)
|
|
3702
|
-
|
|
4216
|
+
const scrollbarCss = source.slice(source.indexOf('var SCROLLBAR_CSS'), source.indexOf('var SEARCH_PANEL_CSS'))
|
|
4217
|
+
assert.match(scrollbarCss, /rgba\(140,140,140,0\.45\)/, 'a neutral light-grey thumb')
|
|
4218
|
+
assert.doesNotMatch(scrollbarCss, /86,182,194/, 'the bars no longer use the teal accent')
|
|
4219
|
+
assert.match(source, /SELECTION_CSS \+ SCROLLBAR_CSS \+ SEARCH_PANEL_CSS \+ TOAST_CSS/, 'injected with the panel styles')
|
|
3703
4220
|
assert.doesNotMatch(source, /SCROLLBAR_CSS[\s\S]{0,800}?scrollbar-gutter/, 'no empty gutter on files that do not overflow')
|
|
3704
4221
|
// BUG6: a start records a size baseline and watches for its first new byte …
|
|
3705
4222
|
assert.match(source, /async function consoleStart\(program\) \{[\s\S]{0,700}?await logSizeOf\(logPath\)/, 'the start records a size baseline')
|
|
@@ -3716,3 +4233,257 @@ test('the editor scrollbars are visible and a start re-reads its log', async ()
|
|
|
3716
4233
|
const host = await readFile(new URL('../lib/index.js', import.meta.url), 'utf8')
|
|
3717
4234
|
assert.match(host, /if \(text !== '' && send\('append', \{ ok: true, text \}\) === false\) \{[\s\S]{0,200}?await snapshot\(\)/, 'a dropped frame re-snapshots')
|
|
3718
4235
|
})
|
|
4236
|
+
|
|
4237
|
+
test('Ctrl+D deletes the current line in the CodeMirror editor', async () => {
|
|
4238
|
+
const { readFile } = await import('node:fs/promises')
|
|
4239
|
+
const src = await readFile(new URL('../src/chunks/codemirror.js', import.meta.url), 'utf8')
|
|
4240
|
+
const built = await readFile(new URL('../lib/client-codemirror.js', import.meta.url), 'utf8')
|
|
4241
|
+
// VS Code muscle memory: Ctrl/Cmd+D removes the line under the cursor. The
|
|
4242
|
+
// binding has to sit BEFORE `...searchKeymap`, whose own Mod-d is
|
|
4243
|
+
// selectNextOccurrence — the first binding that returns true wins.
|
|
4244
|
+
const custom = src.indexOf("{ key: 'Mod-d', preventDefault: true, run: deleteLine }")
|
|
4245
|
+
assert.ok(custom !== -1, 'the source binds Mod-d to deleteLine')
|
|
4246
|
+
assert.ok(custom < src.indexOf('...searchKeymap'), "and it outranks searchKeymap's selectNextOccurrence")
|
|
4247
|
+
assert.match(built, /key: "Mod-d",\s*\n\s*preventDefault: true,\s*\n\s*run: deleteLine/, 'the committed chunk ships the binding')
|
|
4248
|
+
// The right-click menu teaches the same chord.
|
|
4249
|
+
assert.match(src, /\{ label: '删除当前行', shortcut: 'Ctrl\+D \/ Ctrl\+Shift\+K'/)
|
|
4250
|
+
assert.match(built, /shortcut: "Ctrl\+D \/ Ctrl\+Shift\+K"/)
|
|
4251
|
+
})
|
|
4252
|
+
|
|
4253
|
+
test('the log level filter keeps ERROR/WARN headers and their indented continuations', () => {
|
|
4254
|
+
const lines = [
|
|
4255
|
+
{ level: 'INFO', parts: [{ text: 'ok' }] },
|
|
4256
|
+
{ level: 'WARN', parts: [{ text: 'slow' }] },
|
|
4257
|
+
{ level: 'ERROR', parts: [{ text: 'boom' }] },
|
|
4258
|
+
{ level: undefined, parts: [{ text: ' at a.B(C.java:1)' }] },
|
|
4259
|
+
{ level: undefined, parts: [{ text: 'plain note' }] },
|
|
4260
|
+
]
|
|
4261
|
+
assert.deepEqual(T.filterLogLines(lines, 'all'), lines, 'all means all')
|
|
4262
|
+
assert.deepEqual(T.filterLogLines(lines, 'warn').map(T.logLineText), ['slow', 'boom', ' at a.B(C.java:1)'], 'WARN keeps ERROR and indented stack frames')
|
|
4263
|
+
assert.deepEqual(T.filterLogLines(lines, 'error').map(T.logLineText), ['boom', ' at a.B(C.java:1)'], 'ERROR keeps ERROR and indented stack frames')
|
|
4264
|
+
assert.equal(T.logLineVisible({ level: 'FATAL' }, 'error'), true, 'FATAL counts as an error')
|
|
4265
|
+
assert.equal(T.logLineVisible({ level: 'INFO' }, 'error'), false, 'INFO is filtered out')
|
|
4266
|
+
})
|
|
4267
|
+
|
|
4268
|
+
test('the diff and test panes float over a still-mounted editor', async () => {
|
|
4269
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4270
|
+
// The editor must NOT be swapped out (a remount would drop CodeMirror's undo
|
|
4271
|
+
// history), so the panes are siblings rendered after `body`.
|
|
4272
|
+
assert.doesNotMatch(source, /testPane !== null \? testPane : diffPane !== null \? diffPane : body/,
|
|
4273
|
+
'the editor is never replaced by an overlay')
|
|
4274
|
+
assert.match(source, /body,\n\s+previewing \? previewPaneNode\(\) : null,\n\s+diffPane,\n\s+testPane,\n\s+previewToggleBar\(\)\)\)/,
|
|
4275
|
+
'both panes render on top of the mounted editor, with the preview chip last')
|
|
4276
|
+
// The panes are column stacks with a scrollable pre, not the centred media
|
|
4277
|
+
// wrapper that clipped the diff to the right half.
|
|
4278
|
+
assert.match(source, /style: S\.paneOverlay, 'data-editor-diff'/)
|
|
4279
|
+
assert.match(source, /style: S\.paneOverlay, 'data-test-pane'/)
|
|
4280
|
+
assert.match(source, /style: S\.paneScroll,\n\s+'data-diff-body'/)
|
|
4281
|
+
// Two gutters (old → new) per row.
|
|
4282
|
+
assert.match(source, /h\('span', \{ style: S\.diffNum \}, row\.kind === 'add' \? '' : String\(oldLine\)\)/)
|
|
4283
|
+
assert.match(source, /h\('span', \{ style: S\.diffNum \}, row\.kind === 'del' \? '' : String\(newLine\)\)/)
|
|
4284
|
+
})
|
|
4285
|
+
|
|
4286
|
+
test('the sidebar console opens the config as a sidebar file resource', async () => {
|
|
4287
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4288
|
+
// The right-sidebar tab body hands the panel the client ctx, so the compact
|
|
4289
|
+
// console can reach `sidebarRight.openResource` (a workbench is never mounted
|
|
4290
|
+
// there — the old code handed the path to a workbench that did not exist).
|
|
4291
|
+
assert.match(source, /h\(ProgramsPanel, Object\.assign\(\{\}, props, \{ clientCtx: ctx \}\)\)/)
|
|
4292
|
+
assert.match(source, /typeof sidebar\.openResource === 'function'/)
|
|
4293
|
+
assert.match(source, /sidebar\.openResource\(officialPreviewAddress\(\{ sessionId: sessionId, cwd: cwd \}, path\)\)/)
|
|
4294
|
+
assert.match(source, /已在右侧栏打开 /, 'the console reports where the config went')
|
|
4295
|
+
})
|
|
4296
|
+
|
|
4297
|
+
test('the mask names the action and a window opened on a program auto-debugs it', async () => {
|
|
4298
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4299
|
+
|
|
4300
|
+
// The mask label follows the ACTION. Deriving it from `alive` made a debug
|
|
4301
|
+
// restart of a running program say 停止中 — the host stops it on the way.
|
|
4302
|
+
assert.equal(T.busyMaskText(true, 'debug'), '调试中…')
|
|
4303
|
+
assert.equal(T.busyMaskText(true, 'stop'), '停止中…')
|
|
4304
|
+
assert.equal(T.busyMaskText(true, 'restart'), '重启中…')
|
|
4305
|
+
assert.equal(T.busyMaskText(false, 'start'), '启动中…')
|
|
4306
|
+
assert.equal(T.busyMaskText(true, 'start'), '停止中…', 'a stale `alive` still reads as a stop')
|
|
4307
|
+
// The tooltip spells out the action: "正在调试中" read like a plain stop.
|
|
4308
|
+
assert.equal(T.busyMaskTitle(true, 'debug', 'ris-codegen'), '正在以调试模式重启 ris-codegen…')
|
|
4309
|
+
assert.equal(T.busyMaskTitle(true, 'restart', 'x'), '正在重启 x…')
|
|
4310
|
+
assert.equal(T.busyMaskTitle(true, 'stop', 'x'), '正在停止 x…')
|
|
4311
|
+
assert.equal(T.busyMaskTitle(false, 'start', 'x'), '正在启动 x…')
|
|
4312
|
+
assert.doesNotMatch(source, /'正在' \+ busyMaskText/)
|
|
4313
|
+
assert.match(source, /var \[consoleBusyKind, setConsoleBusyKind\] = useState\(''\)/)
|
|
4314
|
+
assert.match(source, /var \[busyKind, setBusyKind\] = useState\(''\)/)
|
|
4315
|
+
assert.match(source, /setConsoleBusyKind\('debug'\)/)
|
|
4316
|
+
|
|
4317
|
+
// The standalone window carries its target row as a prop: the tab meta is
|
|
4318
|
+
// workspace-level, so `meta.autoDebug` never arrived and the 🐞 button opened
|
|
4319
|
+
// a window that did NOT start debugging.
|
|
4320
|
+
assert.match(source, /var openProgram = props !== null && props !== undefined && props\.openProgram !== null/)
|
|
4321
|
+
assert.match(source, /useState\(metaLogPath !== '' \? metaLogPath : openLogPath\)/, 'the pane opens on that program\'s log')
|
|
4322
|
+
assert.match(source, /openProgram: active !== null && active !== undefined && typeof active === 'object' \? active : null/)
|
|
4323
|
+
const effect = source.slice(source.indexOf('var autoDebugRef = useRef('), source.indexOf('// ── small pieces'))
|
|
4324
|
+
// It must wait for the row instead of firing on an empty program list.
|
|
4325
|
+
assert.match(effect, /\[debuggable, debugProgramId, ui\.busy, sessionId\]/)
|
|
4326
|
+
assert.match(effect, /debugProgramId === undefined/, 'waits until the row is known')
|
|
4327
|
+
assert.match(effect, /autoDebugRef\.current = false/)
|
|
4328
|
+
assert.match(effect, /void startDebug\(\)/)
|
|
4329
|
+
})
|
|
4330
|
+
|
|
4331
|
+
test('search hits survive a pick and the shortcut selects the query', async () => {
|
|
4332
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4333
|
+
const cache = new Map()
|
|
4334
|
+
assert.equal(T.rememberSearchEntry(cache, 'name:a', { matches: ['a'] }, 2), cache)
|
|
4335
|
+
T.rememberSearchEntry(cache, 'content:a', [{ path: 'a' }], 2)
|
|
4336
|
+
T.rememberSearchEntry(cache, 'name:ab', { matches: ['ab'] }, 2)
|
|
4337
|
+
assert.deepEqual([...cache.keys()], ['content:a', 'name:ab'], 'the oldest entry is evicted past the limit')
|
|
4338
|
+
T.rememberSearchEntry(cache, 'content:a', [], 2)
|
|
4339
|
+
assert.deepEqual([...cache.keys()], ['name:ab', 'content:a'], 'a touched key moves to the newest slot')
|
|
4340
|
+
|
|
4341
|
+
// Picking a row must NOT wipe the query/results (reopen the same hit for free).
|
|
4342
|
+
const pick = source.slice(source.indexOf('function pickSearchHit('), source.indexOf('function openContentHit('))
|
|
4343
|
+
assert.doesNotMatch(pick, /setTreeQuery\(''\)/, 'the query stays after a pick')
|
|
4344
|
+
assert.doesNotMatch(pick, /setSearchHits\(null\)/, 'the result set stays after a pick')
|
|
4345
|
+
const contentPick = source.slice(source.indexOf('function openContentHit('), source.indexOf('var runningSignature'))
|
|
4346
|
+
assert.doesNotMatch(contentPick, /setTreeQuery\(''\)/, 'a content pick keeps the query too')
|
|
4347
|
+
// Both searches cache their payloads keyed by the query text.
|
|
4348
|
+
assert.match(source, /searchCacheRef\.current\.get\('name:' \+ text\)/)
|
|
4349
|
+
assert.match(source, /rememberSearchEntry\(searchCacheRef\.current, 'content:' \+ text/)
|
|
4350
|
+
// The shortcut focuses THROUGH an effect so select() survives the repaint.
|
|
4351
|
+
assert.match(source, /searchFocusPendingRef\.current = true/)
|
|
4352
|
+
// The dropdown is focus-owned: a pick blurs the box, so re-clicking it fires
|
|
4353
|
+
// focus again and shows the cached rows.
|
|
4354
|
+
assert.match(pick, /searchInputRef\.current\.blur\(\)/, 'a pick blurs the box')
|
|
4355
|
+
assert.match(source, /searchFocused !== true\n\s+\? null/, 'the dropdown only renders while focused')
|
|
4356
|
+
// A content pick must survive a non-promise `openPath` and a late-registering
|
|
4357
|
+
// viewer: retry a few frames, then forward the query into the editor's find.
|
|
4358
|
+
assert.doesNotMatch(source, /void openPath\(path\)\.then\(/)
|
|
4359
|
+
assert.match(source, /function applyFind\(attempt\)/)
|
|
4360
|
+
assert.match(source, /typeof opened\.then === 'function'/)
|
|
4361
|
+
assert.match(source, /controls\.searchFor\(needle, hit\.line\)/)
|
|
4362
|
+
// A viewer that registers late still receives the pending find (chunk load).
|
|
4363
|
+
assert.match(source, /pendingFindRef\.current\[path\] = \{ needle: needle, line: hit\.line \}/)
|
|
4364
|
+
assert.match(source, /var pending = pendingFindRef\.current\[path\]/)
|
|
4365
|
+
// Synthetic window-target events must not make `contains` throw a UI toast.
|
|
4366
|
+
assert.match(source, /typeof target\.nodeType !== 'number'\) return false/)
|
|
4367
|
+
assert.match(source, /input\.focus\(\)\n\s+input\.select\(\)/)
|
|
4368
|
+
assert.match(source, /\[searchFocusNonce, treeQuery\]/, 'the select effect runs after the value paints')
|
|
4369
|
+
})
|
|
4370
|
+
|
|
4371
|
+
test('the editor find panel matches the IDE chrome', async () => {
|
|
4372
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4373
|
+
assert.match(source, /var SEARCH_PANEL_CSS = /)
|
|
4374
|
+
const css = source.slice(source.indexOf('var SEARCH_PANEL_CSS'), source.indexOf('var SELECTION_CSS'))
|
|
4375
|
+
// Two rows in one grid: both inputs sit in the same 1fr column (equal width) and
|
|
4376
|
+
// the buttons in six fixed 24px columns, so find-row and replace-row line up.
|
|
4377
|
+
assert.match(css, /\[data-workbench="ris-ide"\] \.cm-search\{display:grid;grid-template-columns:minmax\(0,1fr\) repeat\(6,24px\)/)
|
|
4378
|
+
assert.match(css, /\[data-workbench="ris-ide"\] \.cm-search input\{grid-column:1;width:100%;min-width:0/)
|
|
4379
|
+
assert.match(css, /\[data-workbench="ris-ide"\] \.cm-search button\{height:22px;width:24px/)
|
|
4380
|
+
assert.match(css, /button\[aria-pressed="true"\]\{background:rgba\(86,182,194,0\.30\)/)
|
|
4381
|
+
// Count on the replace row, between the input column and the replace buttons.
|
|
4382
|
+
assert.match(css, /\.dsh-find-count\{grid-row:2;grid-column:2 \/ span 4/)
|
|
4383
|
+
assert.match(css, /background:color-mix\(in srgb, currentColor 6%, transparent\) !important/)
|
|
4384
|
+
assert.match(css, /background-image:none !important/, 'CM gradient buttons are neutralised')
|
|
4385
|
+
assert.match(css, /\.cm-searchMatch-selected\{background:rgba\(255,150,40,0\.42\)/)
|
|
4386
|
+
// The panel itself is the IDE's own (chunk-side), not CodeMirror's built-in one.
|
|
4387
|
+
const chunkSource = await readFile(new URL('../src/chunks/codemirror.js', import.meta.url), 'utf8')
|
|
4388
|
+
const chunkBuilt = await readFile(new URL('../lib/client-codemirror.js', import.meta.url), 'utf8')
|
|
4389
|
+
assert.match(chunkSource, /search\(\{ top: true, createPanel: ideFindPanel \}\)/)
|
|
4390
|
+
assert.match(chunkBuilt, /createPanel: ideFindPanel/)
|
|
4391
|
+
assert.match(chunkSource, /const searchInput = makeInput\('search'/)
|
|
4392
|
+
assert.match(chunkSource, /const replaceInput = makeInput\('replace'/)
|
|
4393
|
+
assert.match(chunkSource, /const replaceButton = makeButton\('replace'/)
|
|
4394
|
+
assert.match(chunkSource, /const replaceAllButton = makeButton\('replace-all'/)
|
|
4395
|
+
assert.match(chunkSource, /setAttribute\('aria-pressed'/, 'toggles report their state')
|
|
4396
|
+
assert.match(chunkSource, /const apply = \(patch, jump\) =>/, 'one query-commit helper drives every control')
|
|
4397
|
+
assert.match(chunkBuilt, /data-find-action/)
|
|
4398
|
+
assert.match(source, /SELECTION_CSS \+ SCROLLBAR_CSS \+ SEARCH_PANEL_CSS \+ TOAST_CSS/, 'injected with the panel styles')
|
|
4399
|
+
// The content search drives the panel through the registered CM handle.
|
|
4400
|
+
assert.match(source, /props\.onToolbarControls\(handle\)/, 'the CM handle is registered')
|
|
4401
|
+
assert.match(source, /props\.onToolbarControls\(null\)/, 'and unregistered on destroy')
|
|
4402
|
+
})
|
|
4403
|
+
|
|
4404
|
+
test('the search dropdown paints a window and appends rows on scroll', async () => {
|
|
4405
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4406
|
+
// Hundreds of content hits used to be painted in full on every re-open of the
|
|
4407
|
+
// box; the dropdown now slices the row model and grows it near the bottom.
|
|
4408
|
+
assert.match(source, /var SEARCH_ROWS_FIRST = 40/)
|
|
4409
|
+
assert.match(source, /var SEARCH_ROWS_MORE = 60/)
|
|
4410
|
+
assert.match(source, /rows\.slice\(0, rowLimit\)\.map\(function \(row\) \{/)
|
|
4411
|
+
assert.match(source, /rowsNode\.push\(h\('div', \{[\s\S]{0,200}'data-search-more'/, 'a truncated list says how many rows are left')
|
|
4412
|
+
assert.match(source, /'data-search-more': String\(rows\.length - rowLimit\)/)
|
|
4413
|
+
assert.match(source, /if \(box\.scrollTop \+ box\.clientHeight < box\.scrollHeight - 120\) return/, 'near the bottom appends')
|
|
4414
|
+
assert.match(source, /setRowLimit\(Math\.min\(rows\.length, rowLimit \+ SEARCH_ROWS_MORE\)\)/)
|
|
4415
|
+
assert.match(source, /if \(active < 0 \|\| active < rowLimit\) return[\s\S]{0,200}setRowLimit\(Math\.min\(rows\.length, Math\.max\(rowLimit \+ SEARCH_ROWS_MORE, active \+ 1\)\)\)/,
|
|
4416
|
+
'the keyboard widens the window instead of walking past the drawn rows')
|
|
4417
|
+
})
|
|
4418
|
+
|
|
4419
|
+
test('the diff pane shows added, removed and unchanged lines', () => {
|
|
4420
|
+
const rows = T.lineDiff('a\nb\nc', 'a\nB\nc\nd')
|
|
4421
|
+
const kinds = rows.map((row) => row.kind + ':' + row.text)
|
|
4422
|
+
// The LCS walks backwards and emits the ADD first when a line was replaced,
|
|
4423
|
+
// so the diff reads "+B" above "-b".
|
|
4424
|
+
assert.deepEqual(kinds, ['same:a', 'add:B', 'del:b', 'same:c', 'add:d'])
|
|
4425
|
+
assert.deepEqual(T.lineDiff('', ''), [], 'identical empty documents have no rows')
|
|
4426
|
+
})
|
|
4427
|
+
|
|
4428
|
+
test('a Java test file resolves to a reactor root, module and class selector', () => {
|
|
4429
|
+
const cwd = '/w'
|
|
4430
|
+
const target = T.testRunTarget('/w/ris/ris-model/ris-model-biz/src/test/java/cn/com/ris/DemoTest.java', cwd)
|
|
4431
|
+
assert.deepEqual(target, {
|
|
4432
|
+
reactorCwd: '/w/ris',
|
|
4433
|
+
module: 'ris-model/ris-model-biz',
|
|
4434
|
+
test: 'cn.com.ris.DemoTest',
|
|
4435
|
+
className: 'cn.com.ris.DemoTest',
|
|
4436
|
+
})
|
|
4437
|
+
assert.equal(T.testRunTarget('/w/ris/ris-model/ris-model-biz/src/main/java/A.java', cwd), null, 'main sources are not tests')
|
|
4438
|
+
assert.equal(T.testRunTarget('/w/ris/DemoTest.java', cwd), null, 'a file outside src/test/java has no target')
|
|
4439
|
+
assert.equal(T.testRunTarget('/etc/DemoTest.java', cwd), null, 'files outside the workspace are ignored')
|
|
4440
|
+
const rootModule = T.testRunTarget('/w/ris/src/test/java/A.java', cwd)
|
|
4441
|
+
assert.equal(rootModule.module, '.', 'a reactor-root test uses -pl .')
|
|
4442
|
+
})
|
|
4443
|
+
|
|
4444
|
+
test('content hits render in the same dropdown, with line numbers and the content row', { skip: !reactIsReal ? 'React unavailable for SSR' : false }, () => {
|
|
4445
|
+
const { renderToStaticMarkup } = require(`${REACT_ROOT}/react-dom/server`)
|
|
4446
|
+
const markup = renderToStaticMarkup(React.createElement(T.SearchResults, {
|
|
4447
|
+
hits: { matches: ['/w/A.java'], dirs: {} },
|
|
4448
|
+
content: [{ path: '/w/A.java', line: 12, text: 'return value;' }],
|
|
4449
|
+
query: 'value',
|
|
4450
|
+
fontRatio: 1,
|
|
4451
|
+
}))
|
|
4452
|
+
assert.match(markup, /匹配 2 个/, 'one file row + one content row')
|
|
4453
|
+
assert.match(markup, /(文件 1 · 内容 1 处)/, 'the header breaks the count down')
|
|
4454
|
+
assert.match(markup, /data-search-hit="content"[^>]*data-search-line="12"/, 'the content row carries its line number')
|
|
4455
|
+
assert.match(markup, /data-search-hit-icon="content"/, 'content rows have their own icon')
|
|
4456
|
+
})
|
|
4457
|
+
|
|
4458
|
+
test('a dialog keeps the anchor it opened at when the pointer moves or clicks again', async () => {
|
|
4459
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4460
|
+
// The point is frozen on open, not read live on every render: a second
|
|
4461
|
+
// pointerdown used to re-anchor the dialog and it jumped out from the cursor.
|
|
4462
|
+
assert.match(source, /var dialogPointRef = useRef\(null\)/, 'a frozen anchor ref exists')
|
|
4463
|
+
assert.match(source, /var anyDialogOpen = prompt !== null \|\| pendingDelete !== null/, 'opening is detected from both dialogs')
|
|
4464
|
+
assert.match(source, /if \(anyDialogOpen === false\) dialogPointRef\.current = null/, 'closing releases the anchor')
|
|
4465
|
+
assert.match(source, /else if \(dialogPointRef\.current === null && pointerRef\.current !== null\) dialogPointRef\.current = pointerRef\.current/, 'opening pins the pointer once')
|
|
4466
|
+
const anchorFn = source.slice(source.indexOf('function dialogAnchor('), source.indexOf('function dialogAnchor(') + 700)
|
|
4467
|
+
assert.match(anchorFn, /var point = dialogPointRef\.current/, 'dialogAnchor reads the frozen point')
|
|
4468
|
+
assert.doesNotMatch(anchorFn, /var point = pointerRef\.current/, 'dialogAnchor no longer reads the live pointer')
|
|
4469
|
+
})
|
|
4470
|
+
|
|
4471
|
+
test('a folder row only expands; the context menu\'s 进入 re-roots with an 上级 row to walk back', async () => {
|
|
4472
|
+
const source = await readFile(new URL('../lib/client.js', import.meta.url), 'utf8')
|
|
4473
|
+
const region = source.slice(source.indexOf('function IdeTree('), source.indexOf('function IdeEditor('))
|
|
4474
|
+
assert.match(region, /var \[rootTrail, setRootTrail\] = useState\(\[\]\)/, 'the tree keeps a root stack')
|
|
4475
|
+
assert.match(region, /var activeRoot = rootTrail\.length > 0 \? rootTrail\[rootTrail\.length - 1\] : rootPath/, 'the last stack entry is the rendered root')
|
|
4476
|
+
assert.match(region, /void loadLevel\(activeRoot, false\)\s*\}, \[activeRoot\]\)/, 'a new root loads itself')
|
|
4477
|
+
assert.match(region, /function openDirRoot\(path\) \{/, 'the deliberate gesture re-roots the tree')
|
|
4478
|
+
assert.match(region, /function closeDirRoot\(\) \{/, 'the 上级 row pops one level')
|
|
4479
|
+
assert.match(region, /toggle\(entry\)\n\s*if \(treeListRef\.current !== null\) treeListRef\.current\.focus/, 'a folder click expands like its twisty')
|
|
4480
|
+
assert.doesNotMatch(region, /onDoubleClick:/, 'no hidden double-click gesture')
|
|
4481
|
+
assert.match(region, /'data-tree-action': 'enter-dir'/, 'the context menu carries an explicit 进入 entry')
|
|
4482
|
+
assert.match(region, /onClick: function \(\) \{ openDirRoot\(treeMenu\.entry\.path\) \}/, '进入 re-roots the tree')
|
|
4483
|
+
assert.match(region, /'data-tree-submenu-panel': 'new'/, '新建文件 opens a flyout panel')
|
|
4484
|
+
assert.match(region, /setMenuSub\(\{ left: Math\.round\(rect\.width\), top: Math\.round\(rect\.top - treeMenu\.y\) \}\)/, 'the flyout anchors to the menu')
|
|
4485
|
+
assert.match(region, /'data-tree-up': '1'/, 'the 上级 row is rendered when the root stack is non-empty')
|
|
4486
|
+
assert.match(region, /'data-tree-root': activeRoot,/, 'the list announces the active root')
|
|
4487
|
+
assert.match(region, /if \(locateRequest\.kind === 'dir'\) openDirRoot\(locateRequest\.path\)/, 'picking a folder search hit re-roots too')
|
|
4488
|
+
assert.match(region, /walk\(activeRoot, 0, \{\}\)/, 'Ctrl+A walks the active root')
|
|
4489
|
+
})
|