dsh-gufa-code 1.3.63 → 1.3.65

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/client.js CHANGED
@@ -16,7 +16,7 @@ const GUFA_NS = 'gufa-code'
16
16
  const G = {}
17
17
  G.NS = GUFA_NS
18
18
  /** 客户端构建标记(排查页面是否加载了新代码时看标题栏) */
19
- G.BUILD = '1.3.63'
19
+ G.BUILD = '1.3.65'
20
20
  G.PANEL_ID = 'gufa-code'
21
21
  /** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
22
22
  G.pendingEntryWorkspace = null
@@ -199,15 +199,23 @@ const DICT_ZH = {
199
199
  'search.searching': '搜索中…',
200
200
  'search.idle': '输入关键字搜索整个项目',
201
201
  'search.noResult': '没有找到匹配结果',
202
- 'search.summary': '{count} 个结果 · {files} 个文件',
202
+ 'search.summary': '{files} 个文件中有 {count} 个结果',
203
203
  'search.truncated': '结果过多已截断,请缩小范围',
204
204
  'search.error': '搜索失败',
205
205
  'search.replaceToggle': '显示/隐藏替换',
206
+ 'search.include': '包含的文件',
207
+ 'search.exclude': '排除的文件',
208
+ 'search.includePlaceholder': '例如 *.js, src/**',
209
+ 'search.excludePlaceholder': '例如 **/*.min.js, test/**',
210
+ 'search.preserveCase': '保留大小写(AB)',
211
+ 'search.replaceOne': '替换此匹配',
212
+ 'search.dismiss': '忽略此匹配',
213
+ 'search.openInEditor': '在编辑器中打开',
214
+ 'search.stale': '匹配位置已变化,已重新搜索',
206
215
  'search.replacePlaceholder': '替换为…',
207
216
  'search.replaceAll': '全部替换',
208
217
  'search.replaceThisFile': '替换此文件',
209
218
  'search.replacing': '替换中…',
210
- 'search.replaced': '已替换 {count} 处({files} 个文件)',
211
219
  'search.confirmReplace': '确定替换 {count} 处({files} 个文件)?直接写文件,编辑器撤销无效。',
212
220
  'search.confirmYes': '确定替换',
213
221
  'search.confirmNo': '取消',
@@ -248,11 +256,9 @@ const DICT_ZH = {
248
256
  'git.behindCount': '待拉取',
249
257
  'git.pull': '拉取',
250
258
  'git.noUpstreamHint': '当前分支还没有上游:点标题栏 ↑ 推送一次即可自动创建上游(git push -u)',
251
- 'git.pushDone': '已推送(如需首次建立上游会自动 -u)',
252
259
  'git.discardFile': '还原该文件的改动',
253
260
  'git.autoStageHint': '提交时会自动暂存所有未暂存改动(也可以先手动选择要暂存的文件)',
254
261
  'git.commitNeedsMessage': '请先填写提交信息,再按 ⌘⇧↵ 提交',
255
- 'git.commitDone': '提交成功',
256
262
  'git.more': '更多操作',
257
263
  'git.viewDiff': '查看改动对比',
258
264
  'git.copyPath': '复制文件路径',
@@ -280,8 +286,6 @@ const DICT_ZH = {
280
286
  'diff.stageFile': '暂存文件',
281
287
  'git.discardAll': '撤销所有未暂存改动',
282
288
  'git.discardConfirm': '再点一次确认撤销(未跟踪文件不会被删除)',
283
- 'git.discardDone': '已撤销所有改动(未跟踪文件保留)',
284
- 'git.pullDone': '拉取完成',
285
289
  'git.committed': '已提交',
286
290
  'git.refresh': '刷新',
287
291
  'git.staged': '已暂存',
@@ -441,15 +445,23 @@ const DICT_EN = {
441
445
  'search.searching': 'Searching…',
442
446
  'search.idle': 'Type a keyword to search the whole project',
443
447
  'search.noResult': 'No matches found',
444
- 'search.summary': '{count} results · {files} files',
448
+ 'search.summary': '{count} results in {files} files',
445
449
  'search.truncated': 'Too many results, truncated — narrow the query',
446
450
  'search.error': 'Search failed',
447
451
  'search.replaceToggle': 'Show / hide replace',
452
+ 'search.include': 'files to include',
453
+ 'search.exclude': 'files to exclude',
454
+ 'search.includePlaceholder': 'e.g. *.js, src/**',
455
+ 'search.excludePlaceholder': 'e.g. **/*.min.js, test/**',
456
+ 'search.preserveCase': 'Preserve case (AB)',
457
+ 'search.replaceOne': 'Replace this match',
458
+ 'search.dismiss': 'Dismiss this match',
459
+ 'search.openInEditor': 'Open in editor',
460
+ 'search.stale': 'Match moved; search refreshed',
448
461
  'search.replacePlaceholder': 'Replace with…',
449
462
  'search.replaceAll': 'Replace all',
450
463
  'search.replaceThisFile': 'Replace in this file',
451
464
  'search.replacing': 'Replacing…',
452
- 'search.replaced': 'Replaced {count} occurrences ({files} files)',
453
465
  'search.confirmReplace': 'Replace {count} occurrences in {files} files? This writes files directly; editor undo will not work.',
454
466
  'search.confirmYes': 'Replace',
455
467
  'search.confirmNo': 'Cancel',
@@ -490,11 +502,9 @@ const DICT_EN = {
490
502
  'git.behindCount': 'to pull',
491
503
  'git.pull': 'Pull',
492
504
  'git.noUpstreamHint': 'No upstream for this branch yet: click ↑ in the header to push once (auto git push -u)',
493
- 'git.pushDone': 'Pushed',
494
505
  'git.discardFile': 'Revert this file',
495
506
  'git.autoStageHint': 'Committing auto-stages all unstaged changes',
496
507
  'git.commitNeedsMessage': 'Write a commit message first, then press ⌘⇧↵',
497
- 'git.commitDone': 'Committed',
498
508
  'git.more': 'More actions',
499
509
  'git.viewDiff': 'View diff',
500
510
  'git.copyPath': 'Copy file path',
@@ -522,8 +532,6 @@ const DICT_EN = {
522
532
  'diff.stageFile': 'Stage file',
523
533
  'git.discardAll': 'Discard all unstaged changes',
524
534
  'git.discardConfirm': 'Click again to confirm (untracked files are kept)',
525
- 'git.discardDone': 'All changes discarded (untracked files kept)',
526
- 'git.pullDone': 'Pull complete',
527
535
  'git.committed': 'Committed',
528
536
  'git.refresh': 'Refresh',
529
537
  'git.staged': 'Staged',
@@ -1733,10 +1741,26 @@ html[data-platform=darwin][data-fullscreen] .gufa-titlebar{height:44px;padding-l
1733
1741
  .gufa-search-action[data-primary]{background:var(--gufa-accent);border-color:var(--gufa-accent);color:#fff}
1734
1742
  .gufa-search-confirm{margin:6px 8px 0;padding:7px 9px;border-radius:7px;border:1px solid var(--gufa-accent);background:color-mix(in srgb, var(--gufa-accent) 12%, transparent);font-size:11.5px;line-height:1.55;color:var(--gufa-text)}
1735
1743
  .gufa-search-confirm-actions{display:flex;justify-content:flex-end;gap:6px;margin-top:6px}
1736
- .gufa-search-notice{margin:6px 8px 0;padding:5px 9px;border-radius:7px;font-size:11.5px;color:var(--dsw-alias-state-success-primary);border:1px solid color-mix(in srgb, var(--dsw-alias-state-success-primary) 45%, transparent)}
1737
1744
  .gufa-search-error{margin:6px 8px 0;padding:5px 9px;border-radius:7px;font-size:11.5px;color:var(--dsw-alias-state-error-primary);border:1px solid color-mix(in srgb, var(--dsw-alias-state-error-primary) 45%, transparent)}
1738
1745
  .gufa-search-file-replace{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;margin-left:2px;border-radius:4px;color:var(--gufa-text-dim);cursor:pointer}
1739
1746
  .gufa-search-file-replace:hover{background:var(--gufa-active);color:var(--gufa-text)}
1747
+ .gufa-search-file-replace{opacity:0;transition:opacity .12s ease}
1748
+ .gufa-search-file-head:hover .gufa-search-file-replace,.gufa-search-file-head:focus-within .gufa-search-file-replace{opacity:1}
1749
+ .gufa-search-match{min-height:23px;align-items:center}
1750
+ .gufa-search-match-actions{display:none;flex:0 0 auto;align-items:center;gap:4px;margin-left:auto}
1751
+ .gufa-search-match:hover .gufa-search-match-actions,.gufa-search-match:focus-within .gufa-search-match-actions{display:flex}
1752
+ .gufa-search-row-action{display:inline-flex;align-items:center;justify-content:center;width:18px;height:18px;border-radius:4px;color:var(--gufa-text-dim);cursor:pointer}
1753
+ .gufa-search-row-action:hover{background:var(--gufa-active);color:var(--gufa-text)}
1754
+ .gufa-search-filter{display:flex;flex-direction:column;gap:3px;margin-top:5px}
1755
+ .gufa-search-filter-label{font-size:10.5px;color:var(--gufa-text-dim)}
1756
+ .gufa-search-filter-input{width:100%;height:24px;padding:0 8px;border-radius:6px;border:1px solid var(--gufa-border);background:var(--gufa-layer2);color:var(--gufa-text);font-size:11.5px;outline:none}
1757
+ .gufa-search-filter-input:focus{border-color:var(--gufa-accent)}
1758
+ .gufa-search-filter-input::placeholder{color:var(--gufa-text-dim)}
1759
+ .gufa-search-summarybar{display:flex;align-items:center;gap:8px}
1760
+ .gufa-search-summarybar .gufa-search-summary{flex:1 1 auto;margin-left:0}
1761
+ .gufa-search-summarybar .gufa-search-link{flex:0 0 auto}
1762
+ .gufa-search-link{border:0;background:transparent;color:var(--gufa-accent);font-size:11px;cursor:pointer;padding:0}
1763
+ .gufa-search-link:hover{text-decoration:underline}
1740
1764
 
1741
1765
  .gufa-tree-chevron{width:14px;flex:0 0 auto;opacity:.7;display:flex;align-items:center;justify-content:center}
1742
1766
  .gufa-tree-icon{width:15px;flex:0 0 auto;opacity:.85;display:flex;align-items:center;justify-content:center}
@@ -1854,15 +1878,6 @@ html[data-gufa-ide] .liang-skin-backdrop{display:none!important}
1854
1878
  .gufa-git-sync[data-active]{color:var(--gufa-accent)}
1855
1879
  .gufa-git-sync-count{font-size:10.5px;font-variant-numeric:tabular-nums;min-width:8px;text-align:center}
1856
1880
  .gufa-git-sync[data-active] .gufa-git-sync-count{font-weight:700}
1857
- .gufa-info-banner{display:flex;align-items:center;gap:6px;margin:8px 10px 0;padding:4px 8px;border-radius:6px;font-size:11.5px;
1858
- color:var(--dsw-alias-state-success-primary, #3fa66f);border:1px solid color-mix(in srgb, currentColor 35%, transparent);
1859
- background:color-mix(in srgb, currentColor 10%, transparent)}
1860
- .gufa-toast-success{position:fixed;top:14px;left:50%;transform:translateX(-50%);z-index:2147483300;
1861
- display:flex;align-items:center;gap:6px;padding:6px 14px;border-radius:999px;font-size:12px;pointer-events:none;
1862
- color:var(--dsw-alias-state-success-primary, #3fb950);
1863
- background:color-mix(in srgb, #3fb950 16%, var(--gufa-solid-overlay-bg, #1c1c1c));
1864
- border:1px solid color-mix(in srgb, #3fb950 50%, transparent);
1865
- box-shadow:0 8px 24px rgba(0,0,0,.35);backdrop-filter:blur(8px)}
1866
1881
  /* 资源管理器:Git 改动状态颜色(M/A/D/R/??) */
1867
1882
  .gufa-tree-row[data-git-status="M"] .gufa-tree-name{color:#e5c07b}
1868
1883
  .gufa-tree-row[data-git-status="A"] .gufa-tree-name{color:#3fb950}
@@ -7006,7 +7021,6 @@ G.Explorer = function Explorer(props) {
7006
7021
  await loadDir(targetDir)
7007
7022
  await loadDir('')
7008
7023
  props.onChanged?.()
7009
- showNotice(`已粘贴 ${written.length} 个文件到 ${targetDir === '' ? '项目根目录' : targetDir}`)
7010
7024
  } catch (error) {
7011
7025
  showNotice(`粘贴失败:${G.errorText(error)}`)
7012
7026
  }
@@ -7322,18 +7336,21 @@ G.SearchPanel = function SearchPanel(props) {
7322
7336
  const t = G.useT()
7323
7337
  const root = props.root
7324
7338
  const [query, setQuery] = useState('')
7339
+ const [replacement, setReplacement] = useState('')
7325
7340
  const [caseSensitive, setCaseSensitive] = useState(false)
7326
7341
  const [regex, setRegex] = useState(false)
7342
+ const [preserveCase, setPreserveCase] = useState(false)
7343
+ const [includeText, setIncludeText] = useState('')
7344
+ const [excludeText, setExcludeText] = useState('')
7345
+ const [replaceOpen, setReplaceOpen] = useState(false)
7327
7346
  const [status, setStatus] = useState('idle')
7328
7347
  const [result, setResult] = useState(null)
7329
7348
  const [error, setError] = useState('')
7330
7349
  const [collapsed, setCollapsed] = useState({})
7331
- const [replaceOpen, setReplaceOpen] = useState(false)
7332
- const [replacement, setReplacement] = useState('')
7333
- const [replacing, setReplacing] = useState(false)
7350
+ const [ignored, setIgnored] = useState(() => new Set())
7334
7351
  const [confirming, setConfirming] = useState(null)
7352
+ const [replacing, setReplacing] = useState(false)
7335
7353
  const [replaceError, setReplaceError] = useState('')
7336
- const [notice, setNotice] = useState('')
7337
7354
  const inputRef = useRef(null)
7338
7355
  const requestRef = useRef(0)
7339
7356
 
@@ -7362,13 +7379,20 @@ G.SearchPanel = function SearchPanel(props) {
7362
7379
  setStatus('loading')
7363
7380
  setError('')
7364
7381
  try {
7365
- const value = await G.api('fs.search', {
7382
+ const found = await G.api('fs.search', {
7366
7383
  root,
7367
7384
  query: text,
7368
- options: { caseSensitive, regex, maxFiles: 200, maxMatches: 500 },
7385
+ options: {
7386
+ caseSensitive,
7387
+ regex,
7388
+ include: includeText,
7389
+ exclude: excludeText,
7390
+ maxFiles: 200,
7391
+ maxMatches: 500,
7392
+ },
7369
7393
  })
7370
7394
  if (seq !== requestRef.current) return
7371
- setResult(value)
7395
+ setResult(found)
7372
7396
  setStatus('ready')
7373
7397
  } catch (err) {
7374
7398
  if (seq !== requestRef.current) return
@@ -7376,42 +7400,7 @@ G.SearchPanel = function SearchPanel(props) {
7376
7400
  setError(G.errorText(err))
7377
7401
  setStatus('error')
7378
7402
  }
7379
- }, [root, caseSensitive, regex])
7380
-
7381
- const requestReplace = useCallback((paths, count, files) => {
7382
- if (typeof root !== 'string' || root === '' || query.trim() === '' || replacing) return
7383
- setReplaceError('')
7384
- setNotice('')
7385
- setConfirming({ paths: Array.isArray(paths) ? paths : null, count: Number(count) || 0, files: Number(files) || 0 })
7386
- }, [root, query, replacing])
7387
-
7388
- const doReplace = useCallback(async () => {
7389
- const pending = confirming
7390
- if (pending === null || replacing) return
7391
- setConfirming(null)
7392
- setReplacing(true)
7393
- setReplaceError('')
7394
- setNotice('')
7395
- try {
7396
- await props.onBeforeReplace?.()
7397
- const value = await G.api('fs.replace', {
7398
- root,
7399
- query: query.trim(),
7400
- replacement,
7401
- options: { caseSensitive, regex },
7402
- paths: Array.isArray(pending.paths) ? pending.paths : undefined,
7403
- })
7404
- const count = Number(value?.replacedCount) || 0
7405
- const replacedFiles = Array.isArray(value?.replacedFiles) ? value.replacedFiles : []
7406
- setNotice(t('search.replaced', { count, files: replacedFiles.length }))
7407
- await props.onFilesChanged?.(replacedFiles)
7408
- await runSearch(query)
7409
- } catch (error) {
7410
- setReplaceError(G.errorText(error))
7411
- } finally {
7412
- setReplacing(false)
7413
- }
7414
- }, [confirming, replacing, props.onBeforeReplace, props.onFilesChanged, root, query, replacement, caseSensitive, regex, runSearch, t])
7403
+ }, [root, caseSensitive, regex, includeText, excludeText])
7415
7404
 
7416
7405
  /* 输入防抖搜索(回车立即搜索) */
7417
7406
  useEffect(() => {
@@ -7427,6 +7416,11 @@ G.SearchPanel = function SearchPanel(props) {
7427
7416
  return () => window.clearTimeout(timer)
7428
7417
  }, [query, runSearch, root])
7429
7418
 
7419
+ /* 搜索条件变化后,之前「忽略的匹配」不再适用 */
7420
+ useEffect(() => {
7421
+ setIgnored(new Set())
7422
+ }, [query, caseSensitive, regex, includeText, excludeText])
7423
+
7430
7424
  /* 快捷键/按钮打开搜索面板时聚焦输入框 */
7431
7425
  useEffect(() => {
7432
7426
  if (G.bus === null || G.bus === undefined || typeof G.bus.on !== 'function') return undefined
@@ -7437,12 +7431,28 @@ G.SearchPanel = function SearchPanel(props) {
7437
7431
  if (props.active === true) focusInput()
7438
7432
  }, [props.active, focusInput])
7439
7433
 
7434
+ const matchKey = useCallback((path, match) => `${path}:${match.line}:${match.column}`, [])
7435
+
7436
+ /* 过滤掉用户手动「忽略」的匹配,并重新汇总数量 */
7437
+ const view = useMemo(() => {
7438
+ if (result === null) return null
7439
+ const files = []
7440
+ let total = 0
7441
+ for (const file of result.files) {
7442
+ const matches = file.matches.filter((match) => !ignored.has(matchKey(file.path, match)))
7443
+ if (matches.length === 0) continue
7444
+ files.push({ path: file.path, matches })
7445
+ total += matches.length
7446
+ }
7447
+ return { ...result, files, total }
7448
+ }, [result, ignored, matchKey])
7449
+
7440
7450
  const summary = (() => {
7441
7451
  if (status === 'loading') return t('search.searching')
7442
- if (status === 'error' || result === null) return ''
7443
- if (result.total === 0) return result.truncated === true ? t('search.truncated') : t('search.noResult')
7444
- const base = t('search.summary', { count: result.total, files: result.files.length })
7445
- return result.truncated === true ? `${base} · ${t('search.truncated')}` : base
7452
+ if (status === 'error' || view === null) return ''
7453
+ if (view.total === 0) return view.truncated === true ? t('search.truncated') : t('search.noResult')
7454
+ const base = t('search.summary', { count: view.total, files: view.files.length })
7455
+ return view.truncated === true ? `${base} · ${t('search.truncated')}` : base
7446
7456
  })()
7447
7457
 
7448
7458
  const highlight = (match) => {
@@ -7458,6 +7468,81 @@ G.SearchPanel = function SearchPanel(props) {
7458
7468
  ]
7459
7469
  }
7460
7470
 
7471
+ const applyReplace = useCallback(async (payload) => {
7472
+ if (typeof root !== 'string' || root === '' || replacing) return
7473
+ setReplacing(true)
7474
+ setReplaceError('')
7475
+ try {
7476
+ await props.onBeforeReplace?.()
7477
+ const value = await G.api('fs.replace', payload)
7478
+ if (value?.stale === true) {
7479
+ setReplaceError(t('search.stale'))
7480
+ setIgnored(new Set())
7481
+ await runSearch(query)
7482
+ return
7483
+ }
7484
+ const files = Array.isArray(value?.replacedFiles) ? value.replacedFiles : []
7485
+ await props.onFilesChanged?.(files)
7486
+ setIgnored(new Set())
7487
+ await runSearch(query)
7488
+ } catch (err) {
7489
+ setReplaceError(G.errorText(err))
7490
+ } finally {
7491
+ setReplacing(false)
7492
+ }
7493
+ }, [root, replacing, props.onBeforeReplace, props.onFilesChanged, t, runSearch, query])
7494
+
7495
+ const requestReplaceAll = () => {
7496
+ if (view === null || view.total === 0 || replacing) return
7497
+ setReplaceError('')
7498
+ setConfirming({ count: view.total, files: view.files.length })
7499
+ }
7500
+ const doReplaceAll = () => {
7501
+ const pending = confirming
7502
+ setConfirming(null)
7503
+ if (pending === null) return
7504
+ void applyReplace({
7505
+ root,
7506
+ query: query.trim(),
7507
+ replacement,
7508
+ options: { caseSensitive, regex, preserveCase, include: includeText, exclude: excludeText },
7509
+ })
7510
+ }
7511
+ const replaceFile = (file) => {
7512
+ if (replacing) return
7513
+ void applyReplace({
7514
+ root,
7515
+ query: query.trim(),
7516
+ replacement,
7517
+ options: { caseSensitive, regex, preserveCase },
7518
+ paths: [file.path],
7519
+ })
7520
+ }
7521
+ const replaceOne = (path, match) => {
7522
+ if (replacing) return
7523
+ void applyReplace({
7524
+ root,
7525
+ query: query.trim(),
7526
+ replacement,
7527
+ options: { caseSensitive, regex, preserveCase },
7528
+ target: { path, line: match.line, column: match.column },
7529
+ })
7530
+ }
7531
+ const dismiss = (path, match) => {
7532
+ setIgnored((current) => {
7533
+ const next = new Set(current)
7534
+ next.add(matchKey(path, match))
7535
+ return next
7536
+ })
7537
+ }
7538
+ const openFirst = () => {
7539
+ const file = view?.files?.[0]
7540
+ const match = file?.matches?.[0]
7541
+ if (file !== undefined && file !== null && match !== undefined && match !== null) {
7542
+ props.onOpenFile?.(file.path, match.line, match.column)
7543
+ }
7544
+ }
7545
+
7461
7546
  const body = (() => {
7462
7547
  if (typeof root !== 'string' || root === '') {
7463
7548
  return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, t('explorer.openProjectFirst'))
@@ -7467,25 +7552,31 @@ G.SearchPanel = function SearchPanel(props) {
7467
7552
  }
7468
7553
  if (status === 'idle') return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, t('search.idle'))
7469
7554
  if (status === 'loading') return h('div', { className: 'gufa-hint', style: { padding: '10px 12px', display: 'flex', gap: 8, alignItems: 'center' } }, h(G.Spinner), t('search.searching'))
7470
- if (result === null || result.total === 0) {
7471
- const emptyText = result !== null && result.truncated === true ? t('search.truncated') : t('search.noResult')
7555
+ if (view === null || view.total === 0) {
7556
+ const emptyText = view !== null && view.truncated === true ? t('search.truncated') : t('search.noResult')
7472
7557
  return h('div', { className: 'gufa-hint', style: { padding: '10px 12px' } }, emptyText)
7473
7558
  }
7474
7559
  return h(
7475
7560
  'div',
7476
7561
  { className: 'gufa-search-results' },
7477
- ...result.files.map((file) => {
7562
+ ...view.files.map((file) => {
7478
7563
  const isCollapsed = collapsed[file.path] === true
7479
7564
  return h(
7480
7565
  'div',
7481
7566
  { key: file.path, className: 'gufa-search-file' },
7482
7567
  h(
7483
- 'button',
7568
+ 'div',
7484
7569
  {
7485
- type: 'button',
7486
7570
  className: 'gufa-search-file-head',
7571
+ role: 'button',
7572
+ tabIndex: 0,
7487
7573
  title: file.path,
7488
7574
  onClick: () => setCollapsed((current) => ({ ...current, [file.path]: !isCollapsed })),
7575
+ onKeyDown: (event) => {
7576
+ if (event.key !== 'Enter' && event.key !== ' ') return
7577
+ event.preventDefault()
7578
+ setCollapsed((current) => ({ ...current, [file.path]: !isCollapsed }))
7579
+ },
7489
7580
  },
7490
7581
  h(G.Icon, { name: isCollapsed ? 'chevron-right' : 'chevron-down', size: 11 }),
7491
7582
  h('span', { className: 'gufa-search-file-name' }, G.basename(file.path)),
@@ -7501,7 +7592,7 @@ G.SearchPanel = function SearchPanel(props) {
7501
7592
  onClick: (event) => {
7502
7593
  event.stopPropagation()
7503
7594
  event.preventDefault()
7504
- requestReplace([file.path], file.matches.length, 1)
7595
+ replaceFile(file)
7505
7596
  },
7506
7597
  },
7507
7598
  h(G.Icon, { name: 'pencil', size: 11 }),
@@ -7512,16 +7603,56 @@ G.SearchPanel = function SearchPanel(props) {
7512
7603
  ? null
7513
7604
  : file.matches.map((match, index) =>
7514
7605
  h(
7515
- 'button',
7606
+ 'div',
7516
7607
  {
7517
7608
  key: `${file.path}:${match.line}:${match.column}:${index}`,
7518
- type: 'button',
7519
7609
  className: 'gufa-search-match',
7610
+ role: 'button',
7611
+ tabIndex: 0,
7520
7612
  title: `${file.path}:${match.line}:${match.column}`,
7521
7613
  onClick: () => props.onOpenFile?.(file.path, match.line, match.column),
7614
+ onKeyDown: (event) => {
7615
+ if (event.key !== 'Enter') return
7616
+ event.preventDefault()
7617
+ props.onOpenFile?.(file.path, match.line, match.column)
7618
+ },
7522
7619
  },
7523
7620
  h('span', { className: 'gufa-search-line' }, String(match.line)),
7524
7621
  h('span', { className: 'gufa-search-text' }, ...highlight(match)),
7622
+ h(
7623
+ 'span',
7624
+ { className: 'gufa-search-match-actions' },
7625
+ replaceOpen
7626
+ ? h(
7627
+ 'span',
7628
+ {
7629
+ className: 'gufa-search-row-action',
7630
+ title: t('search.replaceOne'),
7631
+ role: 'button',
7632
+ onClick: (event) => {
7633
+ event.stopPropagation()
7634
+ event.preventDefault()
7635
+ replaceOne(file.path, match)
7636
+ },
7637
+ },
7638
+ h(G.Icon, { name: 'pencil', size: 11 }),
7639
+ )
7640
+ : null,
7641
+ h(
7642
+ 'span',
7643
+ {
7644
+ className: 'gufa-search-row-action',
7645
+ title: t('search.dismiss'),
7646
+ role: 'button',
7647
+ onClick: (event) => {
7648
+ event.stopPropagation()
7649
+ event.preventDefault()
7650
+ dismiss(file.path, match)
7651
+ },
7652
+ },
7653
+ h(G.Icon, { name: 'close', size: 11 }),
7654
+ ),
7655
+ ),
7525
7656
  ),
7526
7657
  ),
7527
7658
  )
@@ -7581,7 +7712,6 @@ G.SearchPanel = function SearchPanel(props) {
7581
7712
  title: t('search.regex'),
7582
7713
  onClick: () => setRegex((value) => !value),
7583
7714
  }, '.*'),
7584
- h('span', { className: 'gufa-search-summary', title: summary }, summary),
7585
7715
  ),
7586
7716
  replaceOpen
7587
7717
  ? h(
@@ -7601,9 +7731,16 @@ G.SearchPanel = function SearchPanel(props) {
7601
7731
  onKeyDown: (event) => {
7602
7732
  if (event.key !== 'Enter') return
7603
7733
  event.preventDefault()
7604
- requestReplace(null, result?.total ?? 0, result?.files?.length ?? 0)
7734
+ requestReplaceAll()
7605
7735
  },
7606
7736
  }),
7737
+ h('button', {
7738
+ type: 'button',
7739
+ className: 'gufa-search-toggle',
7740
+ 'data-active': preserveCase ? '' : undefined,
7741
+ title: t('search.preserveCase'),
7742
+ onClick: () => setPreserveCase((value) => !value),
7743
+ }, 'AB'),
7607
7744
  ),
7608
7745
  h(
7609
7746
  'div',
@@ -7614,14 +7751,48 @@ G.SearchPanel = function SearchPanel(props) {
7614
7751
  type: 'button',
7615
7752
  className: 'gufa-search-action',
7616
7753
  'data-primary': '',
7617
- disabled: replacing || result === null || result.total === 0,
7618
- onClick: () => requestReplace(null, result?.total ?? 0, result?.files?.length ?? 0),
7754
+ disabled: replacing || view === null || view.total === 0,
7755
+ onClick: requestReplaceAll,
7619
7756
  },
7620
7757
  replacing ? t('search.replacing') : t('search.replaceAll'),
7621
7758
  ),
7622
7759
  ),
7623
7760
  )
7624
7761
  : null,
7762
+ h(
7763
+ 'label',
7764
+ { className: 'gufa-search-filter' },
7765
+ h('span', { className: 'gufa-search-filter-label' }, t('search.include')),
7766
+ h('input', {
7767
+ className: 'gufa-search-filter-input',
7768
+ type: 'text',
7769
+ value: includeText,
7770
+ placeholder: t('search.includePlaceholder'),
7771
+ spellCheck: false,
7772
+ onChange: (event) => setIncludeText(event.target.value),
7773
+ }),
7774
+ ),
7775
+ h(
7776
+ 'label',
7777
+ { className: 'gufa-search-filter' },
7778
+ h('span', { className: 'gufa-search-filter-label' }, t('search.exclude')),
7779
+ h('input', {
7780
+ className: 'gufa-search-filter-input',
7781
+ type: 'text',
7782
+ value: excludeText,
7783
+ placeholder: t('search.excludePlaceholder'),
7784
+ spellCheck: false,
7785
+ onChange: (event) => setExcludeText(event.target.value),
7786
+ }),
7787
+ ),
7788
+ h(
7789
+ 'div',
7790
+ { className: 'gufa-search-summarybar' },
7791
+ h('span', { className: 'gufa-search-summary', title: summary }, summary),
7792
+ view !== null && view.total > 0
7793
+ ? h('button', { type: 'button', className: 'gufa-search-link', onClick: openFirst }, t('search.openInEditor'))
7794
+ : null,
7795
+ ),
7625
7796
  confirming !== null
7626
7797
  ? h(
7627
7798
  'div',
@@ -7631,11 +7802,10 @@ G.SearchPanel = function SearchPanel(props) {
7631
7802
  'div',
7632
7803
  { className: 'gufa-search-confirm-actions' },
7633
7804
  h('button', { type: 'button', className: 'gufa-search-action', onClick: () => setConfirming(null) }, t('search.confirmNo')),
7634
- h('button', { type: 'button', className: 'gufa-search-action', 'data-primary': '', onClick: () => void doReplace() }, t('search.confirmYes')),
7805
+ h('button', { type: 'button', className: 'gufa-search-action', 'data-primary': '', onClick: doReplaceAll }, t('search.confirmYes')),
7635
7806
  ),
7636
7807
  )
7637
7808
  : null,
7638
- notice !== '' ? h('div', { className: 'gufa-search-notice' }, notice) : null,
7639
7809
  replaceError !== '' ? h('div', { className: 'gufa-search-error' }, `${t('search.replaceError')}:${replaceError}`) : null,
7640
7810
  ),
7641
7811
  h('div', { className: 'gufa-panel-body gufa-scroll' }, body),
@@ -7650,14 +7820,6 @@ G.GitPanel = function GitPanel(props) {
7650
7820
  const [error, setError] = useState('')
7651
7821
  const [pending, setPending] = useState(false)
7652
7822
  const [message, setMessage] = useState('')
7653
- const [info, setInfo] = useState('')
7654
-
7655
- /* 操作结果提示(已推送 / 拉取完成 等)自动消失 */
7656
- useEffect(() => {
7657
- if (info === '') return undefined
7658
- const timer = window.setTimeout(() => setInfo(''), 1500)
7659
- return () => window.clearTimeout(timer)
7660
- }, [info])
7661
7823
  const [discardArmed, setDiscardArmed] = useState(false)
7662
7824
  const [headMenu, setHeadMenu] = useState(null)
7663
7825
  const [rowMenu, setRowMenu] = useState(null)
@@ -7706,7 +7868,6 @@ G.GitPanel = function GitPanel(props) {
7706
7868
  const act = async (fn) => {
7707
7869
  setPending(true)
7708
7870
  setError('')
7709
- setInfo('')
7710
7871
  try {
7711
7872
  await fn()
7712
7873
  await refresh()
@@ -7721,21 +7882,17 @@ G.GitPanel = function GitPanel(props) {
7721
7882
  /* 推送 / 拉取:点 ↑/↓ 直接执行 */
7722
7883
  const push = () => void act(async () => {
7723
7884
  await G.api('git.push', { root })
7724
- setInfo(t('git.pushDone'))
7725
7885
  })
7726
7886
  const pull = () => void act(async () => {
7727
7887
  await G.api('git.pull', { root })
7728
- setInfo(t('git.pullDone'))
7729
7888
  })
7730
7889
 
7731
7890
  /* 推送 / 拉取(新建分支还没有上游时也能直接发布:Host 会自动 -u <remote> <branch>) */
7732
7891
  const pushBranch = () => void act(async () => {
7733
7892
  await G.api('git.push', { root })
7734
- setInfo(t('git.pushDone'))
7735
7893
  })
7736
7894
  const pullBranch = () => void act(async () => {
7737
7895
  await G.api('git.pull', { root })
7738
- setInfo(t('git.pullDone'))
7739
7896
  })
7740
7897
 
7741
7898
  /* 一键撤销所有未暂存改动:第一次点击进入「再点确认」,3 秒后自动取消 */
@@ -7748,7 +7905,6 @@ G.GitPanel = function GitPanel(props) {
7748
7905
  setDiscardArmed(false)
7749
7906
  void act(async () => {
7750
7907
  await G.api('git.discardAll', { root })
7751
- setInfo(t('git.discardDone'))
7752
7908
  })
7753
7909
  }
7754
7910
 
@@ -7757,7 +7913,7 @@ G.GitPanel = function GitPanel(props) {
7757
7913
  if (root === null || pending) return
7758
7914
  const text = typeof message === 'string' ? message.trim() : ''
7759
7915
  if (text === '') {
7760
- setInfo(t('git.commitNeedsMessage'))
7916
+ setError(t('git.commitNeedsMessage'))
7761
7917
  return
7762
7918
  }
7763
7919
  void act(async () => {
@@ -7766,7 +7922,6 @@ G.GitPanel = function GitPanel(props) {
7766
7922
  if (toStage.length > 0) await G.api('git.stage', { root, paths: toStage })
7767
7923
  await G.api('git.commit', { root, message: text })
7768
7924
  setMessage('')
7769
- setInfo(t('git.commitDone'))
7770
7925
  })
7771
7926
  }
7772
7927
  commitRef.current = commit
@@ -7888,7 +8043,6 @@ G.GitPanel = function GitPanel(props) {
7888
8043
  'div',
7889
8044
  { className: 'gufa-panel-body gufa-scroll', style: { display: 'flex', flexDirection: 'column' } },
7890
8045
  error !== '' ? h('div', { className: 'gufa-error-banner' }, G.Icon ? h(G.Icon, { name: 'warn', size: 13 }) : null, error) : null,
7891
- info !== '' ? h('div', { className: 'gufa-info-banner' }, info) : null,
7892
8046
  !root
7893
8047
  ? h(G.Empty, { icon: 'git', title: t('explorer.openProjectFirst') })
7894
8048
  : status === null
@@ -10413,7 +10567,6 @@ G.GufaApp = function GufaApp(props) {
10413
10567
  const [modal, setModal] = useState(null)
10414
10568
  const [shortcutsOpen, setShortcutsOpen] = useState(false)
10415
10569
  const [trashUndo, setTrashUndo] = useState([])
10416
- const [bannerTone, setBannerTone] = useState('error')
10417
10570
  const [branchMenu, setBranchMenu] = useState(null)
10418
10571
  const [workspaceDialog, setWorkspaceDialog] = useState(null)
10419
10572
  const [workspaceSessions, setWorkspaceSessions] = useState({ status: 'idle', sessions: [], groups: [], sessionIds: [], archivedSessionIds: [] })
@@ -10796,28 +10949,11 @@ G.GufaApp = function GufaApp(props) {
10796
10949
  void refreshGit()
10797
10950
  }, [project, patchTab, refreshGit])
10798
10951
 
10799
- /** 顶栏提示:错误常驻红色;成功用绿色 toast,1.2 秒后自动消失。 */
10800
- const successTimerRef = useRef(null)
10952
+ /** 顶栏提示:只显示错误/需要用户处理的提示;成功类操作直接看界面结果,不再弹 toast。 */
10801
10953
  const showBanner = useCallback((text, tone) => {
10802
- if (successTimerRef.current !== null) {
10803
- window.clearTimeout(successTimerRef.current)
10804
- successTimerRef.current = null
10805
- }
10806
- if (tone === 'success') {
10807
- setBannerTone('success')
10808
- setBanner(text)
10809
- successTimerRef.current = window.setTimeout(() => {
10810
- successTimerRef.current = null
10811
- setBanner('')
10812
- }, 1200)
10813
- return
10814
- }
10815
- setBannerTone('error')
10954
+ if (tone === 'success') return
10816
10955
  setBanner(text)
10817
10956
  }, [])
10818
- useEffect(() => () => {
10819
- if (successTimerRef.current !== null) window.clearTimeout(successTimerRef.current)
10820
- }, [])
10821
10957
 
10822
10958
  const closeTab = useCallback((path) => {
10823
10959
  editorBuffersRef.current.delete(path)
@@ -10945,7 +11081,6 @@ G.GufaApp = function GufaApp(props) {
10945
11081
  try {
10946
11082
  await G.api('git.checkout', { root: project.root, branch: name })
10947
11083
  closeBranchMenu()
10948
- showBanner(`已切换到分支 ${name}`, 'success')
10949
11084
  setGitRefreshToken((token) => token + 1)
10950
11085
  setRefreshToken((token) => token + 1)
10951
11086
  void refreshGit()
@@ -10961,7 +11096,6 @@ G.GufaApp = function GufaApp(props) {
10961
11096
  try {
10962
11097
  await G.api('git.createBranch', { root: project.root, name })
10963
11098
  closeBranchMenu()
10964
- showBanner(`已创建并切换到分支 ${name}`, 'success')
10965
11099
  setGitRefreshToken((token) => token + 1)
10966
11100
  setRefreshToken((token) => token + 1)
10967
11101
  void refreshGit()
@@ -11125,7 +11259,6 @@ G.GufaApp = function GufaApp(props) {
11125
11259
  if (project === null) return
11126
11260
  try {
11127
11261
  await G.api('git.discard', { root: project.root, paths: [path] })
11128
- showBanner('已还原该文件的改动', 'success')
11129
11262
  // 改动已还原:关掉该 diff 标签(内容已与暂存区一致)
11130
11263
  setTabs((current) => current.filter((tab) => tab.path !== path))
11131
11264
  setActivePath((current) => (current === path ? null : current))
@@ -11141,7 +11274,6 @@ G.GufaApp = function GufaApp(props) {
11141
11274
  if (project === null) return
11142
11275
  try {
11143
11276
  await G.api('git.stage', { root: project.root, paths: [path] })
11144
- showBanner('已暂存该文件', 'success')
11145
11277
  setGitRefreshToken((token) => token + 1)
11146
11278
  void refreshGit()
11147
11279
  } catch (error) {
@@ -11626,7 +11758,6 @@ G.GufaApp = function GufaApp(props) {
11626
11758
  const missingSet = new Set(missing)
11627
11759
  setTabs((current) => current.filter((tab) => tab !== null && !missingSet.has(tab.path)))
11628
11760
  setActivePath((current) => (current !== null && missingSet.has(current) ? null : current))
11629
- showBanner(`已关闭 ${missing.length} 个已删除文件的标签`, 'success')
11630
11761
  }, [project, tabs, showBanner])
11631
11762
  const pruneMissingTabsRef = useRef(null)
11632
11763
  pruneMissingTabsRef.current = pruneMissingTabs
@@ -11796,7 +11927,6 @@ G.GufaApp = function GufaApp(props) {
11796
11927
  await openProjectPath(workspace.path)
11797
11928
  }
11798
11929
  closeWorkspaceDialog()
11799
- showBanner(`已切换到工作区 ${workspace.title || workspace.path || ''}`, 'success')
11800
11930
  } catch (error) {
11801
11931
  setWorkspaceDialog((current) => (current === null ? current : { ...current, error: G.errorText(error) }))
11802
11932
  }
@@ -11827,7 +11957,6 @@ G.GufaApp = function GufaApp(props) {
11827
11957
  }
11828
11958
  await openProjectPath(directory)
11829
11959
  closeWorkspaceDialog()
11830
- showBanner('已创建工作区', 'success')
11831
11960
  } catch (error) {
11832
11961
  setBanner(G.errorText(error))
11833
11962
  } finally {
@@ -12604,10 +12733,7 @@ G.GufaApp = function GufaApp(props) {
12604
12733
  h(
12605
12734
  'div',
12606
12735
  { className: 'gufa-editor-area' },
12607
- banner !== '' && bannerTone === 'success'
12608
- ? h('div', { className: 'gufa-toast-success' }, h(G.Icon, { name: 'check', size: 13 }), h('span', null, banner))
12609
- : null,
12610
- banner !== '' && bannerTone !== 'success'
12736
+ banner !== ''
12611
12737
  ? h(
12612
12738
  'div',
12613
12739
  { className: 'gufa-error-banner' },