dsh-gufa-code 1.3.54 → 1.3.56
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 +180 -28
- package/desktop/float/bin/gufa-float-macos-arm64 +0 -0
- package/desktop/float/bin/gufa-float-macos-universal +0 -0
- package/desktop/float/bin/gufa-float-macos-x64 +0 -0
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/Info.plist +2 -2
- package/desktop/float//345/217/244/346/263/225/347/274/226/347/250/213/346/202/254/346/265/256/345/261/202.app/Contents/MacOS/gufa-float +0 -0
- package/docs/FLOAT-ACCEPTANCE.md +2 -2
- package/docs/PERFORMANCE.md +37 -0
- package/host/dev.js +10 -52
- package/host/float-platform.js +97 -0
- package/package.json +7 -1
- package/scripts/selftest-host.mjs +50 -0
- package/src/client/20-editor.js +51 -1
- package/src/client/90-app.js +128 -26
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.
|
|
19
|
+
G.BUILD = '1.3.56'
|
|
20
20
|
G.PANEL_ID = 'gufa-code'
|
|
21
21
|
/** 从哪个工作区点进来的(工作区菜单/节点按钮写入,App 启动时消费)。 */
|
|
22
22
|
G.pendingEntryWorkspace = null
|
|
@@ -2690,7 +2690,7 @@ G.FooterAction = function FooterAction(props) {
|
|
|
2690
2690
|
|
|
2691
2691
|
/* ── 组件 ───────────────────────────────────────────────────────────── */
|
|
2692
2692
|
|
|
2693
|
-
|
|
2693
|
+
function GufaEditorPaneComponent(props) {
|
|
2694
2694
|
const tabs = useMemo(() => (Array.isArray(props.tabs) ? props.tabs : []), [props.tabs])
|
|
2695
2695
|
const activePath = typeof props.activePath === 'string' ? props.activePath : null
|
|
2696
2696
|
const root = typeof props.root === 'string' ? props.root : ''
|
|
@@ -3543,6 +3543,56 @@ G.FooterAction = function FooterAction(props) {
|
|
|
3543
3543
|
)
|
|
3544
3544
|
}
|
|
3545
3545
|
|
|
3546
|
+
/* 光标事件外部 store:App 不再为每次光标移动重渲染整个 IDE,状态栏订阅即可。 */
|
|
3547
|
+
G.cursorStore = (() => {
|
|
3548
|
+
const listeners = new Set()
|
|
3549
|
+
let value = null
|
|
3550
|
+
return {
|
|
3551
|
+
get: () => value,
|
|
3552
|
+
subscribe: (listener) => {
|
|
3553
|
+
listeners.add(listener)
|
|
3554
|
+
return () => listeners.delete(listener)
|
|
3555
|
+
},
|
|
3556
|
+
set: (next) => {
|
|
3557
|
+
if (value === next) return
|
|
3558
|
+
if (value !== null && next !== null &&
|
|
3559
|
+
value.path === next.path && value.line === next.line && value.column === next.column &&
|
|
3560
|
+
value.lineCount === next.lineCount && value.selectedText === next.selectedText) return
|
|
3561
|
+
value = next
|
|
3562
|
+
for (const listener of [...listeners]) {
|
|
3563
|
+
try {
|
|
3564
|
+
listener(next)
|
|
3565
|
+
} catch {
|
|
3566
|
+
/* 订阅者异常不影响编辑器 */
|
|
3567
|
+
}
|
|
3568
|
+
}
|
|
3569
|
+
},
|
|
3570
|
+
}
|
|
3571
|
+
})()
|
|
3572
|
+
G.useCursorStore = function useCursorStore() {
|
|
3573
|
+
const [snapshot, setSnapshot] = React.useState(G.cursorStore.get())
|
|
3574
|
+
React.useEffect(() => {
|
|
3575
|
+
setSnapshot(G.cursorStore.get())
|
|
3576
|
+
return G.cursorStore.subscribe(setSnapshot)
|
|
3577
|
+
}, [])
|
|
3578
|
+
return snapshot
|
|
3579
|
+
}
|
|
3580
|
+
/* 状态栏行数/光标:只订阅 cursorStore,光标移动不会触发 App 根组件重渲染。 */
|
|
3581
|
+
G.StatusCursor = function StatusCursor(props) {
|
|
3582
|
+
const activePath = props !== null && props !== undefined ? props.activePath : null
|
|
3583
|
+
const fallbackLineCount = props !== null && props !== undefined && Number.isFinite(props.fallbackLineCount) ? props.fallbackLineCount : 0
|
|
3584
|
+
const cursor = G.useCursorStore()
|
|
3585
|
+
const matched = cursor !== null && cursor.path === activePath
|
|
3586
|
+
const lineCount = matched && Number.isFinite(cursor.lineCount) ? cursor.lineCount : fallbackLineCount
|
|
3587
|
+
const cursorText = matched ? `${G.t('status.ln')} ${cursor.line},${G.t('status.col')} ${cursor.column}` : ''
|
|
3588
|
+
return React.createElement(React.Fragment, null,
|
|
3589
|
+
activePath !== null ? React.createElement('span', { className: 'gufa-status-item' }, `${lineCount} ${G.t('status.lines')}`) : null,
|
|
3590
|
+
cursorText !== '' ? React.createElement('span', { className: 'gufa-status-item' }, cursorText) : null,
|
|
3591
|
+
)
|
|
3592
|
+
}
|
|
3593
|
+
/* EditorPane 只在 props 真正变化时重渲染(光标移动不再穿透到 Monaco 外层)。 */
|
|
3594
|
+
G.EditorPane = typeof React.memo === 'function' ? React.memo(GufaEditorPaneComponent) : GufaEditorPaneComponent
|
|
3595
|
+
|
|
3546
3596
|
/* 纯函数/加载状态测试钩子:供 scripts/test-editor.mjs 在无浏览器环境下校验
|
|
3547
3597
|
* URI、光标推进、主题映射与 loader 失败降级 / 重试 / 单例注入。 */
|
|
3548
3598
|
G.EditorPane.internals = Object.freeze({
|
|
@@ -9815,7 +9865,15 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9815
9865
|
const [banner, setBanner] = useState('')
|
|
9816
9866
|
const [tabs, setTabs] = useState([])
|
|
9817
9867
|
const [activePath, setActivePath] = useState(null)
|
|
9818
|
-
|
|
9868
|
+
/* 选区(给右侧 AI 用)单独更新;光标位置/行数走 G.cursorStore,避免每次按键重渲染整个 IDE。 */
|
|
9869
|
+
const [selection, setSelection] = useState(null)
|
|
9870
|
+
/* 编辑器内容缓冲:Monaco 每次按键只写这里,300ms 停顿后才同步进 tabs(保存/自动保存直接读缓冲)。 */
|
|
9871
|
+
const editorBuffersRef = useRef(new Map())
|
|
9872
|
+
const tabsRef = useRef([])
|
|
9873
|
+
const flushTimerRef = useRef(null)
|
|
9874
|
+
const selectionTimerRef = useRef(null)
|
|
9875
|
+
const pendingSelectionRef = useRef(null)
|
|
9876
|
+
const flushBuffersRef = useRef(null)
|
|
9819
9877
|
const [refreshToken, setRefreshToken] = useState(0)
|
|
9820
9878
|
const [gitRefreshToken, setGitRefreshToken] = useState(0)
|
|
9821
9879
|
const [sshRefreshToken, setSshRefreshToken] = useState(0)
|
|
@@ -9838,6 +9896,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9838
9896
|
const [explorerWidth, explorerDrag] = G.useSplitter({ initial: 260, min: 190, max: 520, storageKey: 'gufa-code:w:explorer' })
|
|
9839
9897
|
const [chatWidth, chatDrag] = G.useSplitter({ initial: 430, min: 320, max: 780, axis: 'x', invert: true, storageKey: 'gufa-code:w:chat' })
|
|
9840
9898
|
const [terminalHeight, terminalDrag] = G.useSplitter({ initial: 230, min: 120, max: 560, axis: 'y', invert: true, storageKey: 'gufa-code:h:terminal' })
|
|
9899
|
+
useEffect(() => {
|
|
9900
|
+
tabsRef.current = tabs
|
|
9901
|
+
}, [tabs])
|
|
9841
9902
|
|
|
9842
9903
|
const patchUi = useCallback((patch) => {
|
|
9843
9904
|
setUi((current) => {
|
|
@@ -9854,7 +9915,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9854
9915
|
writeJson(GUFA_LS.project, value?.root ?? null)
|
|
9855
9916
|
setTabs([])
|
|
9856
9917
|
setActivePath(null)
|
|
9857
|
-
|
|
9918
|
+
setSelection(null)
|
|
9919
|
+
editorBuffersRef.current.clear()
|
|
9920
|
+
if (flushTimerRef.current !== null) { window.clearTimeout(flushTimerRef.current); flushTimerRef.current = null }
|
|
9921
|
+
G.cursorStore.set(null)
|
|
9858
9922
|
setGitStatus(null)
|
|
9859
9923
|
setRefreshToken((token) => token + 1)
|
|
9860
9924
|
setGitRefreshToken((token) => token + 1)
|
|
@@ -9960,6 +10024,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9960
10024
|
/* ── 文件打开 / 保存 / 关闭 ─────────────────────────────────────────── */
|
|
9961
10025
|
const openFile = useCallback(async (path) => {
|
|
9962
10026
|
if (project === null) return
|
|
10027
|
+
flushBuffersRef.current?.()
|
|
9963
10028
|
const existing = tabs.find((tab) => tab.path === path)
|
|
9964
10029
|
if (existing !== undefined) {
|
|
9965
10030
|
setActivePath(path)
|
|
@@ -9982,6 +10047,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9982
10047
|
/* 原子恢复标签集合:按快照顺序、去重、最后激活指定文件(避免 openFile 并发产生重复标签) */
|
|
9983
10048
|
const applyTabs = useCallback(async (paths, active) => {
|
|
9984
10049
|
if (project === null || !Array.isArray(paths)) return
|
|
10050
|
+
flushBuffersRef.current?.()
|
|
9985
10051
|
const docs = []
|
|
9986
10052
|
const seen = new Set()
|
|
9987
10053
|
for (const path of paths.slice(0, 12)) {
|
|
@@ -9994,6 +10060,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
9994
10060
|
/* 快照里的文件可能已被删除:忽略 */
|
|
9995
10061
|
}
|
|
9996
10062
|
}
|
|
10063
|
+
editorBuffersRef.current.clear()
|
|
9997
10064
|
setTabs(docs)
|
|
9998
10065
|
const wanted = typeof active === 'string' && docs.some((doc) => doc.path === active) ? active : (docs.length > 0 ? docs[docs.length - 1].path : null)
|
|
9999
10066
|
setActivePath(wanted)
|
|
@@ -10002,27 +10069,85 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10002
10069
|
const activeTab = useMemo(() => tabs.find((tab) => tab.path === activePath) ?? null, [tabs, activePath])
|
|
10003
10070
|
|
|
10004
10071
|
const patchTab = useCallback((path, patch) => {
|
|
10005
|
-
setTabs((current) =>
|
|
10072
|
+
setTabs((current) => {
|
|
10073
|
+
const next = current.map((tab) => (tab.path === path ? { ...tab, ...patch } : tab))
|
|
10074
|
+
tabsRef.current = next
|
|
10075
|
+
return next
|
|
10076
|
+
})
|
|
10006
10077
|
}, [])
|
|
10007
10078
|
|
|
10008
|
-
|
|
10009
|
-
|
|
10010
|
-
|
|
10011
|
-
)
|
|
10079
|
+
/* 把缓冲内容写回 tabs(停顿 / 保存 / 切换标签时调用),不会在每次按键触发渲染。 */
|
|
10080
|
+
const flushEditorBuffers = useCallback(() => {
|
|
10081
|
+
const buffers = editorBuffersRef.current
|
|
10082
|
+
if (buffers.size === 0) return
|
|
10083
|
+
setTabs((current) => {
|
|
10084
|
+
let changed = false
|
|
10085
|
+
const next = current.map((tab) => {
|
|
10086
|
+
if (tab === null || !buffers.has(tab.path)) return tab
|
|
10087
|
+
const content = buffers.get(tab.path)
|
|
10088
|
+
const dirty = content !== tab.savedContent
|
|
10089
|
+
if (tab.content === content && tab.dirty === dirty) return tab
|
|
10090
|
+
changed = true
|
|
10091
|
+
return { ...tab, content, dirty }
|
|
10092
|
+
})
|
|
10093
|
+
if (!changed) return current
|
|
10094
|
+
tabsRef.current = next
|
|
10095
|
+
return next
|
|
10096
|
+
})
|
|
10012
10097
|
}, [])
|
|
10013
10098
|
|
|
10099
|
+
flushBuffersRef.current = flushEditorBuffers
|
|
10100
|
+
|
|
10101
|
+
const scheduleEditorFlush = useCallback(() => {
|
|
10102
|
+
if (flushTimerRef.current !== null) window.clearTimeout(flushTimerRef.current)
|
|
10103
|
+
flushTimerRef.current = window.setTimeout(() => {
|
|
10104
|
+
flushTimerRef.current = null
|
|
10105
|
+
flushEditorBuffers()
|
|
10106
|
+
}, 300)
|
|
10107
|
+
}, [flushEditorBuffers])
|
|
10108
|
+
|
|
10109
|
+
const changeFile = useCallback((path, content) => {
|
|
10110
|
+
editorBuffersRef.current.set(path, content)
|
|
10111
|
+
const tab = tabsRef.current.find((item) => item !== null && item.path === path)
|
|
10112
|
+
if (tab !== undefined && tab.dirty !== (content !== tab.savedContent)) {
|
|
10113
|
+
/* 只在「干净 ↔ 脏」变化时立刻更新标签圆点,避免每个按键重渲染整棵 IDE 树。 */
|
|
10114
|
+
setTabs((current) => {
|
|
10115
|
+
let changed = false
|
|
10116
|
+
const next = current.map((item) => {
|
|
10117
|
+
if (item === null || item.path !== path) return item
|
|
10118
|
+
const dirty = content !== item.savedContent
|
|
10119
|
+
if (item.dirty === dirty) return item
|
|
10120
|
+
changed = true
|
|
10121
|
+
return { ...item, dirty }
|
|
10122
|
+
})
|
|
10123
|
+
if (!changed) return current
|
|
10124
|
+
tabsRef.current = next
|
|
10125
|
+
return next
|
|
10126
|
+
})
|
|
10127
|
+
}
|
|
10128
|
+
scheduleEditorFlush()
|
|
10129
|
+
}, [scheduleEditorFlush])
|
|
10130
|
+
|
|
10014
10131
|
const saveFile = useCallback(async (path) => {
|
|
10015
10132
|
if (project === null) return
|
|
10016
|
-
const tab =
|
|
10017
|
-
if (tab === undefined
|
|
10133
|
+
const tab = tabsRef.current.find((item) => item !== null && item.path === path)
|
|
10134
|
+
if (tab === undefined) return
|
|
10135
|
+
/* 缓冲里可能有比 tabs 更新的内容(按键后 300ms 内保存/自动保存) */
|
|
10136
|
+
const content = editorBuffersRef.current.has(path) ? editorBuffersRef.current.get(path) : tab.content
|
|
10137
|
+
if (content === tab.savedContent) {
|
|
10138
|
+
editorBuffersRef.current.delete(path)
|
|
10139
|
+
if (tab.dirty === true) patchTab(path, { content, dirty: false })
|
|
10140
|
+
return
|
|
10141
|
+
}
|
|
10018
10142
|
try {
|
|
10019
10143
|
const result = await G.api('fs.write', {
|
|
10020
10144
|
root: project.root,
|
|
10021
10145
|
path: tab.path,
|
|
10022
|
-
content
|
|
10146
|
+
content,
|
|
10023
10147
|
expectedRevision: tab.revision,
|
|
10024
10148
|
})
|
|
10025
|
-
|
|
10149
|
+
editorBuffersRef.current.delete(path)
|
|
10150
|
+
patchTab(path, { content, revision: result.revision, savedRevision: result.revision, savedContent: content, dirty: false, size: result.size })
|
|
10026
10151
|
setBanner('')
|
|
10027
10152
|
// 内容保存不改变目录结构:只刷新 Git 状态,不重载文件树(避免整页闪烁)
|
|
10028
10153
|
setGitRefreshToken((token) => token + 1)
|
|
@@ -10031,7 +10156,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10031
10156
|
if (error.code === 'revision-conflict') setBanner(t('editor.saveConflict'))
|
|
10032
10157
|
else setBanner(G.errorText(error))
|
|
10033
10158
|
}
|
|
10034
|
-
}, [project,
|
|
10159
|
+
}, [project, patchTab, refreshGit, t])
|
|
10035
10160
|
|
|
10036
10161
|
/** 顶栏提示:错误常驻红色;成功用绿色 toast,1.2 秒后自动消失。 */
|
|
10037
10162
|
const successTimerRef = useRef(null)
|
|
@@ -10057,6 +10182,8 @@ G.GufaApp = function GufaApp(props) {
|
|
|
10057
10182
|
}, [])
|
|
10058
10183
|
|
|
10059
10184
|
const closeTab = useCallback((path) => {
|
|
10185
|
+
editorBuffersRef.current.delete(path)
|
|
10186
|
+
flushBuffersRef.current?.()
|
|
10060
10187
|
setTabs((current) => {
|
|
10061
10188
|
const next = current.filter((tab) => tab.path !== path)
|
|
10062
10189
|
if (activePath === path) {
|
|
@@ -11367,10 +11494,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11367
11494
|
return { path: activeTab.path, content: activeTab.content ?? '', language: activeTab.language }
|
|
11368
11495
|
}, [activeTab])
|
|
11369
11496
|
|
|
11370
|
-
const selectionForChat = useMemo(() =>
|
|
11371
|
-
if (cursor === null || typeof cursor.selectedText !== 'string' || cursor.selectedText === '') return null
|
|
11372
|
-
return { text: cursor.selectedText, path: cursor.path, line: cursor.line, column: cursor.column }
|
|
11373
|
-
}, [cursor])
|
|
11497
|
+
const selectionForChat = useMemo(() => selection, [selection])
|
|
11374
11498
|
|
|
11375
11499
|
/* ── IDE 专属快捷键(参考 VS Code;经典模式下不生效) ──────────────── */
|
|
11376
11500
|
const editorFocusedRef = useRef(false)
|
|
@@ -11582,7 +11706,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11582
11706
|
role: 'tab',
|
|
11583
11707
|
tabIndex: 0,
|
|
11584
11708
|
title: tab.title !== undefined && tab.title !== null ? tab.title : tab.path,
|
|
11585
|
-
onClick: () =>
|
|
11709
|
+
onClick: () => handleSelectTab(tab.path),
|
|
11586
11710
|
onAuxClick: (event) => { if (event.button === 1) closeTabWithConfirm(tab.path) },
|
|
11587
11711
|
},
|
|
11588
11712
|
h(G.Icon, { name: 'file', size: 13 }),
|
|
@@ -11637,10 +11761,39 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11637
11761
|
)
|
|
11638
11762
|
: null
|
|
11639
11763
|
|
|
11640
|
-
const
|
|
11641
|
-
|
|
11642
|
-
|
|
11643
|
-
|
|
11764
|
+
const handleEditorCursor = useCallback((value) => {
|
|
11765
|
+
if (value === null || value === undefined) return
|
|
11766
|
+
/* 状态栏订阅 cursorStore,不再触发 App 根组件渲染 */
|
|
11767
|
+
G.cursorStore.set(value)
|
|
11768
|
+
const selectedText = typeof value.selectedText === 'string' ? value.selectedText : ''
|
|
11769
|
+
if (selectedText === '') {
|
|
11770
|
+
if (selectionTimerRef.current !== null) { window.clearTimeout(selectionTimerRef.current); selectionTimerRef.current = null }
|
|
11771
|
+
pendingSelectionRef.current = null
|
|
11772
|
+
setSelection((current) => (current === null ? current : null))
|
|
11773
|
+
return
|
|
11774
|
+
}
|
|
11775
|
+
pendingSelectionRef.current = { text: selectedText, path: value.path, line: value.line, column: value.column }
|
|
11776
|
+
if (selectionTimerRef.current !== null) return
|
|
11777
|
+
selectionTimerRef.current = window.setTimeout(() => {
|
|
11778
|
+
selectionTimerRef.current = null
|
|
11779
|
+
const latest = pendingSelectionRef.current
|
|
11780
|
+
if (latest === null) return
|
|
11781
|
+
setSelection((current) => {
|
|
11782
|
+
if (current !== null && current.text === latest.text && current.path === latest.path &&
|
|
11783
|
+
current.line === latest.line && current.column === latest.column) return current
|
|
11784
|
+
return latest
|
|
11785
|
+
})
|
|
11786
|
+
}, 180)
|
|
11787
|
+
}, [])
|
|
11788
|
+
const handleEditorSave = useCallback((path) => { void saveFile(path) }, [saveFile])
|
|
11789
|
+
const handleSelectTab = useCallback((path) => {
|
|
11790
|
+
flushBuffersRef.current?.()
|
|
11791
|
+
setActivePath(path)
|
|
11792
|
+
}, [])
|
|
11793
|
+
useEffect(() => () => {
|
|
11794
|
+
if (flushTimerRef.current !== null) { window.clearTimeout(flushTimerRef.current); flushTimerRef.current = null }
|
|
11795
|
+
if (selectionTimerRef.current !== null) { window.clearTimeout(selectionTimerRef.current); selectionTimerRef.current = null }
|
|
11796
|
+
}, [])
|
|
11644
11797
|
|
|
11645
11798
|
const statusBranch = project?.isGit === true && gitStatus?.branch ? gitStatus.branch : null
|
|
11646
11799
|
const lineCount = activeTab === null || activeTab.kind === 'graph' ? 0 : String(activeTab.content ?? '').split('\n').length
|
|
@@ -11835,12 +11988,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11835
11988
|
theme,
|
|
11836
11989
|
palette: solidPalette,
|
|
11837
11990
|
root: project?.root ?? '',
|
|
11838
|
-
onSelectTab:
|
|
11991
|
+
onSelectTab: handleSelectTab,
|
|
11839
11992
|
onCloseTab: closeTabWithConfirm,
|
|
11840
11993
|
onChange: changeFile,
|
|
11841
|
-
onSave:
|
|
11994
|
+
onSave: handleEditorSave,
|
|
11842
11995
|
backdropMode: backdropActive,
|
|
11843
|
-
onCursor:
|
|
11996
|
+
onCursor: handleEditorCursor,
|
|
11844
11997
|
}),
|
|
11845
11998
|
),
|
|
11846
11999
|
),
|
|
@@ -11913,11 +12066,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
11913
12066
|
: h('span', { className: 'gufa-status-item' }, t('status.noGit')),
|
|
11914
12067
|
h('div', { className: 'gufa-status-fill' }),
|
|
11915
12068
|
activeTab !== null ? h('span', { className: 'gufa-status-item' }, activeTab.title !== undefined && activeTab.title !== null ? activeTab.title : G.shortPath(activeTab.path, 56)) : null,
|
|
11916
|
-
activeTab !== null ? h('span', { className: 'gufa-status-item' }, `${lineCount} ${t('status.lines')}`) : null,
|
|
11917
12069
|
activeTab !== null && problems[activeTab.path] !== undefined
|
|
11918
12070
|
? h('span', { className: 'gufa-status-item', style: { color: problems[activeTab.path].errors > 0 ? '#f85149' : '#e5c07b' } }, `${problems[activeTab.path].errors} ✕ ${problems[activeTab.path].warnings} ⚠`)
|
|
11919
12071
|
: null,
|
|
11920
|
-
|
|
12072
|
+
h(G.StatusCursor, { activePath, fallbackLineCount: lineCount }),
|
|
11921
12073
|
activeTab !== null && activeTab.dirty === true ? h('span', { className: 'gufa-status-item', style: { color: 'var(--gufa-accent)' } }, t('status.dirty')) : null,
|
|
11922
12074
|
activeTab !== null && activeTab.dirty !== true ? h('span', { className: 'gufa-status-item' }, G.Icon ? h(G.Icon, { name: 'check', size: 11 }) : null, t('status.saved')) : null,
|
|
11923
12075
|
h('button', {
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
<key>CFBundleDisplayName</key><string>古法编程悬浮层</string>
|
|
8
8
|
<key>CFBundleExecutable</key><string>gufa-float</string>
|
|
9
9
|
<key>CFBundlePackageType</key><string>APPL</string>
|
|
10
|
-
<key>CFBundleShortVersionString</key><string>1.3.
|
|
11
|
-
<key>CFBundleVersion</key><string>1.3.
|
|
10
|
+
<key>CFBundleShortVersionString</key><string>1.3.56</string>
|
|
11
|
+
<key>CFBundleVersion</key><string>1.3.56</string>
|
|
12
12
|
<key>LSUIElement</key><true/>
|
|
13
13
|
<key>NSHighResolutionCapable</key><true/>
|
|
14
14
|
<key>NSPrincipalClass</key><string>NSApplication</string>
|
|
Binary file
|
package/docs/FLOAT-ACCEPTANCE.md
CHANGED
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
|
|
19
19
|
| 平台 | 自动化验证 |
|
|
20
20
|
|---|---|
|
|
21
|
-
| Windows (windows-latest) | ciProbe 加载本地页面 ok:true;真实窗口创建(EnumWindows 数可见窗口);**跟随** notepad 窗口位置/大小、移动后继续跟随;**隐藏/恢复**标题为 "DeepSeek Harness" 的窗口;**状态注入**(页面读回 `gufa-code:float` / `float-state` / `project` / `ui:v1` 全部正确);**透明 composition**(日志 `transparent-mode=composition` + 窗口 `WS_EX_NOREDIRECTIONBITMAP
|
|
22
|
-
| Linux (ubuntu-24.04 + Xvfb + openbox) | ciProbe 加载本地页面 ok:true;真实窗口创建;**跟随** xterm 窗口位置/大小、移动后继续跟随;**状态注入**(同上四项 localStorage 全部正确);**隐藏/恢复**标题为 "DeepSeek Harness" 的 xmessage 窗口(XUnmap→XMap);controlPath 优雅退出 |
|
|
21
|
+
| Windows (windows-latest) | ciProbe 加载本地页面 ok:true;真实窗口创建(EnumWindows 数可见窗口);**跟随** notepad 窗口位置/大小、移动后继续跟随;**隐藏/恢复**标题为 "DeepSeek Harness" 的窗口;**状态注入**(页面读回 `gufa-code:float` / `float-state` / `project` / `ui:v1` 全部正确);**透明 composition**(日志 `transparent-mode=composition` + 窗口 `WS_EX_NOREDIRECTIONBITMAP`);**opaque 回退**(`transparent-mode=windowed reason=payload-opaque` 下窗口/退出正常);**顶部拖动条命中**(WM_NCHITTEST 拖动区 HTCAPTION / 客户区 HTCLIENT);**键盘输入**(SetForegroundWindow+keybd_event 后页面收到 keydown);controlPath 优雅退出 |
|
|
22
|
+
| Linux (ubuntu-24.04 + Xvfb + openbox) | ciProbe 加载本地页面 ok:true;真实窗口创建;**跟随** xterm 窗口位置/大小、移动后继续跟随;**状态注入**(同上四项 localStorage 全部正确);**隐藏/恢复**标题为 "DeepSeek Harness" 的 xmessage 窗口(XUnmap→XMap);**RGBA 透明路径**(xcompmgr 下日志 `使用 RGBA visual`);**键盘输入**(xdotool XTEST 发送 G 后页面收到 keydown);controlPath 优雅退出 |
|
|
23
23
|
| macOS (macos-latest) | universal 构建 + 窗口列表辅助功能检查 |
|
|
24
24
|
|
|
25
25
|
所以剩下的真机验收重点:真实 DSH 集成(主窗口隐藏/唤回)、多显示器/DPI、外观(Windows 首版不透明)、Wayland(Linux)等 CI 覆盖不到的部分。
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# 编辑器性能设计(避免按键「不跟手」)
|
|
2
|
+
|
|
3
|
+
Monaco 本身很快;古法编程编辑器之前卡顿的主要原因是 **React 状态更新链路**:
|
|
4
|
+
每按一个键,Monaco 的 `onDidChangeModelContent` 会同步到 App 状态,导致整个 IDE
|
|
5
|
+
(资源管理器、终端、右侧 AI 会话、状态栏…)重渲染一次;光标位置变化又触发一次。
|
|
6
|
+
快捷键连打时就是每秒几十次整树渲染。
|
|
7
|
+
|
|
8
|
+
## 现在的实现
|
|
9
|
+
|
|
10
|
+
1. **内容缓冲区(不在每次按键时 setState)**
|
|
11
|
+
- `onChange(path, content)` 只写入 `editorBuffersRef`(ref,不触发渲染);
|
|
12
|
+
- 只有「干净 ↔ 脏」变化时更新一次 tabs(标签圆点),每个编辑段最多一次;
|
|
13
|
+
- 停顿 **300ms** 后用 `flushEditorBuffers()` 把缓冲内容同步进 tabs(一次渲染);
|
|
14
|
+
- 保存 / 自动保存(700ms)/ 关闭标签前**直接读缓冲**,所以不会写入旧内容;
|
|
15
|
+
- 撤销到与磁盘一致时会自动变回「已保存」。
|
|
16
|
+
|
|
17
|
+
2. **光标/行号走外部 store**
|
|
18
|
+
- Monaco 的光标事件写入 `G.cursorStore`(module-level,去重 + 订阅),
|
|
19
|
+
- 状态栏的 `G.StatusCursor` 用 `useSyncExternalStore` 订阅,**只渲染状态栏那一小块**;
|
|
20
|
+
- App 根组件不再因为光标移动而重渲染;选区(AI 引用用)180ms 防抖后单独更新。
|
|
21
|
+
|
|
22
|
+
3. **EditorPane 用 React.memo + 稳定回调**
|
|
23
|
+
- 父组件因其它原因重渲染时,只要 tabs/activePath/theme 等 props 没变,Monaco 外层不重渲染;
|
|
24
|
+
- `onChange/onSave/onSelectTab/onCursor` 都用 `useCallback`,依赖只包含真正会变的数据。
|
|
25
|
+
|
|
26
|
+
## 实测(macOS,113 行文本文件)
|
|
27
|
+
|
|
28
|
+
- 连续输入 `abc`:标签立即变脏、状态栏 Ln/Col 正常更新;
|
|
29
|
+
- 自动保存在 700ms 档内把 `abc` 写入磁盘(通过 Host `fs.read` 校验内容 +3 字节);
|
|
30
|
+
- `Cmd+Z` 撤销后自动保存把文件恢复为原始内容(与 baseline 全等);
|
|
31
|
+
- 三套测试 99 / 44 / 19 全过。
|
|
32
|
+
|
|
33
|
+
## 后续可继续优化(未做)
|
|
34
|
+
|
|
35
|
+
- 超大文件(数万行)时 Monaco `model.getValue()` 每次变更复制整个字符串,可改为增量取内容/仅在 flush 时取;
|
|
36
|
+
- 右侧 AI 流式回复时 App 的频繁更新可进一步拆分订阅;
|
|
37
|
+
- 资源管理器大目录可做虚拟滚动。
|
package/host/dev.js
CHANGED
|
@@ -10,6 +10,7 @@ import { promisify } from 'node:util'
|
|
|
10
10
|
import { dirname, join } from 'node:path'
|
|
11
11
|
import { fileURLToPath } from 'node:url'
|
|
12
12
|
import { ApiError } from './context.js'
|
|
13
|
+
import { floatBinaryCandidates, parsePowerShellWindowList, parseTasklistPids, parseWmctrlWindowList } from './float-platform.js'
|
|
13
14
|
|
|
14
15
|
const PLUGIN_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..')
|
|
15
16
|
const DEBUG_LOG_PATH = '/tmp/gufa-code-debug.log'
|
|
@@ -29,28 +30,7 @@ const runFile = promisify(execFile)
|
|
|
29
30
|
/** 查找当前平台编译好的悬浮层 helper。 */
|
|
30
31
|
function floatBinaryPath() {
|
|
31
32
|
const root = join(PLUGIN_ROOT, 'desktop', 'float', 'bin')
|
|
32
|
-
|
|
33
|
-
if (process.platform === 'darwin') {
|
|
34
|
-
const arch = process.arch === 'arm64' ? 'arm64' : 'x64'
|
|
35
|
-
candidates = [
|
|
36
|
-
join(root, `gufa-float-macos-${arch}`),
|
|
37
|
-
join(root, 'gufa-float-macos-universal'),
|
|
38
|
-
join(root, 'gufa-float-macos-arm64'),
|
|
39
|
-
join(root, 'gufa-float-macos-x64'),
|
|
40
|
-
]
|
|
41
|
-
} else if (process.platform === 'win32') {
|
|
42
|
-
candidates = [
|
|
43
|
-
join(root, 'win-x64', 'gufa-float-win.exe'),
|
|
44
|
-
join(root, 'gufa-float-win.exe'),
|
|
45
|
-
]
|
|
46
|
-
} else if (process.platform === 'linux') {
|
|
47
|
-
candidates = [
|
|
48
|
-
join(root, 'linux-x64', 'gufa-float-linux'),
|
|
49
|
-
join(root, 'linux-x64', 'gufa-float-linux-x64'),
|
|
50
|
-
join(root, 'gufa-float-linux'),
|
|
51
|
-
]
|
|
52
|
-
}
|
|
53
|
-
for (const full of candidates) {
|
|
33
|
+
for (const full of floatBinaryCandidates(process.platform, process.arch, root)) {
|
|
54
34
|
if (existsSync(full)) return full
|
|
55
35
|
}
|
|
56
36
|
return null
|
|
@@ -147,13 +127,7 @@ export function register(router, env) {
|
|
|
147
127
|
for (const pid of alive) pids.add(pid)
|
|
148
128
|
try {
|
|
149
129
|
const { stdout } = await runFile('tasklist', ['/FI', 'IMAGENAME eq gufa-float-win.exe', '/FO', 'CSV', '/NH'], { timeout: 5000 })
|
|
150
|
-
for (const
|
|
151
|
-
const match = /^"([^"]+)","(\d+)"/.exec(line.trim())
|
|
152
|
-
if (match !== null) {
|
|
153
|
-
const pid = Number(match[2])
|
|
154
|
-
if (Number.isFinite(pid) && pid > 0) pids.add(pid)
|
|
155
|
-
}
|
|
156
|
-
}
|
|
130
|
+
for (const pid of parseTasklistPids(stdout)) pids.add(pid)
|
|
157
131
|
} catch {
|
|
158
132
|
/* tasklist 不可用:只用 child pid */
|
|
159
133
|
}
|
|
@@ -269,14 +243,10 @@ export function register(router, env) {
|
|
|
269
243
|
"ConvertTo-Json -InputObject ([pscustomobject]@{ ok = $true; accessibility = $true; apps = @($rows) }) -Compress -Depth 5",
|
|
270
244
|
].join('\n')
|
|
271
245
|
const { stdout } = await runFile('powershell', ['-NoProfile', '-NonInteractive', '-Command', script], { timeout: 20_000, maxBuffer: 8 * 1024 * 1024 })
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
if (parsed === null || parsed.ok !== true) throw new ApiError('list-failed', '读取 Windows 窗口列表失败', 500)
|
|
275
|
-
let apps = parsed.apps
|
|
276
|
-
if (!Array.isArray(apps)) apps = apps === null || apps === undefined ? [] : [apps]
|
|
246
|
+
const parsed = parsePowerShellWindowList(stdout)
|
|
247
|
+
if (parsed === null) throw new ApiError('list-failed', '读取 Windows 窗口列表失败', 500)
|
|
277
248
|
const helperPids = new Set(await listFloatPids())
|
|
278
|
-
apps = apps.filter((row) =>
|
|
279
|
-
apps = apps.map((row) => ({ ...row, name: typeof row.name === 'string' && row.name !== '' ? row.name : row.owner }))
|
|
249
|
+
const apps = parsed.apps.filter((row) => !helperPids.has(Number(row.pid)))
|
|
280
250
|
return { ok: true, accessibility: true, apps }
|
|
281
251
|
}
|
|
282
252
|
|
|
@@ -304,25 +274,13 @@ export function register(router, env) {
|
|
|
304
274
|
} catch {
|
|
305
275
|
throw new ApiError('missing-tool', 'Linux 下列出窗口失败:请重新构建 helper,或安装 wmctrl(sudo apt install wmctrl)', 500)
|
|
306
276
|
}
|
|
307
|
-
const apps =
|
|
308
|
-
const seen = new Set()
|
|
309
|
-
for (const line of String(stdout ?? '').split('\n')) {
|
|
310
|
-
const match = /^0x[0-9a-fA-F]+\s+\d+\s+(\d+)\s+(.*)$/.exec(line.trim())
|
|
311
|
-
if (match === null) continue
|
|
312
|
-
const pid = Number(match[1])
|
|
313
|
-
const title = match[2].trim()
|
|
314
|
-
if (!Number.isFinite(pid) || pid <= 0 || title === '') continue
|
|
315
|
-
const key = `${pid}:${title}`
|
|
316
|
-
if (seen.has(key)) continue
|
|
317
|
-
seen.add(key)
|
|
318
|
-
let owner = String(pid)
|
|
277
|
+
const apps = parseWmctrlWindowList(stdout, (pid) => {
|
|
319
278
|
try {
|
|
320
|
-
|
|
279
|
+
return readFileSync(`/proc/${pid}/comm`, 'utf8')
|
|
321
280
|
} catch {
|
|
322
|
-
|
|
281
|
+
return undefined
|
|
323
282
|
}
|
|
324
|
-
|
|
325
|
-
}
|
|
283
|
+
})
|
|
326
284
|
return { ok: true, accessibility: true, apps }
|
|
327
285
|
}
|
|
328
286
|
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 跨平台摸鱼悬浮层:Host 侧纯函数(无 DSH 依赖,可单元测试)。
|
|
3
|
+
*
|
|
4
|
+
* host/dev.js 的 float.* 平台分支用这些函数做「二进制候选路径 / 任务列表解析 /
|
|
5
|
+
* PowerShell 窗口列表解析 / wmctrl 窗口列表解析」。把解析逻辑放这里是为了:
|
|
6
|
+
* 1) 在 macOS 上也能用固定字符串测试 Windows/Linux 两条分支;
|
|
7
|
+
* 2) 避免 dev.js 越堆越大。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/** 当前平台优先使用的 helper 二进制候选(按顺序尝试)。 */
|
|
11
|
+
export function floatBinaryCandidates(platform, arch, binRoot) {
|
|
12
|
+
const join = (name) => `${binRoot.replace(/\/+$/, '')}/${name}`
|
|
13
|
+
if (platform === 'darwin') {
|
|
14
|
+
const macArch = arch === 'arm64' ? 'arm64' : 'x64'
|
|
15
|
+
return [
|
|
16
|
+
join(`gufa-float-macos-${macArch}`),
|
|
17
|
+
join('gufa-float-macos-universal'),
|
|
18
|
+
join('gufa-float-macos-arm64'),
|
|
19
|
+
join('gufa-float-macos-x64'),
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
if (platform === 'win32') {
|
|
23
|
+
return [join('win-x64/gufa-float-win.exe'), join('gufa-float-win.exe')]
|
|
24
|
+
}
|
|
25
|
+
if (platform === 'linux') {
|
|
26
|
+
return [join('linux-x64/gufa-float-linux'), join('linux-x64/gufa-float-linux-x64'), join('gufa-float-linux')]
|
|
27
|
+
}
|
|
28
|
+
return []
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** 解析 `tasklist /FI "IMAGENAME eq gufa-float-win.exe" /FO CSV /NH` 的进程号。 */
|
|
32
|
+
export function parseTasklistPids(stdout) {
|
|
33
|
+
const pids = new Set()
|
|
34
|
+
for (const line of String(stdout ?? '').split('\n')) {
|
|
35
|
+
const match = /^"([^"]+)","(\d+)"/.exec(line.trim())
|
|
36
|
+
if (match !== null) {
|
|
37
|
+
const pid = Number(match[2])
|
|
38
|
+
if (Number.isFinite(pid) && pid > 0) pids.add(pid)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return [...pids]
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 解析 Windows 窗口列表 PowerShell 输出:
|
|
46
|
+
* ConvertTo-Json -InputObject ([pscustomobject]@{ ok=$true; accessibility=$true; apps=@($rows) })
|
|
47
|
+
* 返回 { ok, accessibility, apps } 或 null(解析失败/非 ok)。
|
|
48
|
+
*/
|
|
49
|
+
export function parsePowerShellWindowList(stdout) {
|
|
50
|
+
let parsed = null
|
|
51
|
+
try {
|
|
52
|
+
parsed = JSON.parse(String(stdout ?? '').trim())
|
|
53
|
+
} catch {
|
|
54
|
+
return null
|
|
55
|
+
}
|
|
56
|
+
if (parsed === null || typeof parsed !== 'object' || parsed.ok !== true) return null
|
|
57
|
+
let apps = parsed.apps
|
|
58
|
+
if (!Array.isArray(apps)) apps = apps === null || apps === undefined ? [] : [apps]
|
|
59
|
+
apps = apps
|
|
60
|
+
.filter((row) => row !== null && typeof row === 'object' && Number(row.pid) > 0 &&
|
|
61
|
+
typeof row.title === 'string' && row.title !== '')
|
|
62
|
+
.map((row) => ({
|
|
63
|
+
...row,
|
|
64
|
+
name: typeof row.name === 'string' && row.name !== '' ? row.name : (typeof row.owner === 'string' ? row.owner : String(row.pid)),
|
|
65
|
+
}))
|
|
66
|
+
return { ok: true, accessibility: true, apps }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* 解析 `wmctrl -lp` 输出为窗口列表。
|
|
71
|
+
* @param {string} stdout wmctrl 输出
|
|
72
|
+
* @param {(pid:number)=>string|undefined} readComm 读取进程名(Linux 上读 /proc/<pid>/comm;测试可注入)
|
|
73
|
+
*/
|
|
74
|
+
export function parseWmctrlWindowList(stdout, readComm) {
|
|
75
|
+
const apps = []
|
|
76
|
+
const seen = new Set()
|
|
77
|
+
for (const line of String(stdout ?? '').split('\n')) {
|
|
78
|
+
// 格式:`0x窗口ID 桌面号 PID 主机名 窗口标题`(标题可含空格)
|
|
79
|
+
const match = /^0x[0-9a-fA-F]+\s+\d+\s+(\d+)\s+(\S+)\s+(.*)$/.exec(line.trim())
|
|
80
|
+
if (match === null) continue
|
|
81
|
+
const pid = Number(match[1])
|
|
82
|
+
const title = match[3].trim()
|
|
83
|
+
if (!Number.isFinite(pid) || pid <= 0 || title === '') continue
|
|
84
|
+
const key = `${pid}:${title}`
|
|
85
|
+
if (seen.has(key)) continue
|
|
86
|
+
seen.add(key)
|
|
87
|
+
let owner = String(pid)
|
|
88
|
+
try {
|
|
89
|
+
const comm = readComm(pid)
|
|
90
|
+
if (typeof comm === 'string' && comm.trim() !== '') owner = comm.trim()
|
|
91
|
+
} catch {
|
|
92
|
+
/* 进程可能已退出 */
|
|
93
|
+
}
|
|
94
|
+
apps.push({ pid, name: owner, owner, title, bundleId: owner, windowNumber: apps.length + 1, frontmost: 0 })
|
|
95
|
+
}
|
|
96
|
+
return apps
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-gufa-code",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.56",
|
|
4
4
|
"description": "古法编程 · AI 辅助:一键把 DSH 主面板变成 VS Code 风格 IDE(Monaco 编辑器、文件树、Git、SSH、真实终端 + 右侧官方会话);主张亲手写、每个改动心中有数,AI 是助理、你是第一责任人",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"keywords": [
|
|
@@ -66,5 +66,11 @@
|
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|
|
69
|
+
},
|
|
70
|
+
"scripts": {
|
|
71
|
+
"test": "node scripts/selftest-client.mjs && node scripts/selftest-host.mjs && node scripts/test-editor.mjs",
|
|
72
|
+
"build:client": "node scripts/build-client.mjs",
|
|
73
|
+
"build:float:macos": "./scripts/build-float-macos.sh",
|
|
74
|
+
"build:float:linux": "./scripts/build-float-linux.sh"
|
|
69
75
|
}
|
|
70
76
|
}
|
|
@@ -10,6 +10,7 @@ import { tmpdir } from 'node:os'
|
|
|
10
10
|
import { join } from 'node:path'
|
|
11
11
|
|
|
12
12
|
import * as assets from '../host/assets.js'
|
|
13
|
+
import * as floatPlatform from '../host/float-platform.js'
|
|
13
14
|
import * as chat from '../host/chat.js'
|
|
14
15
|
import * as fs from '../host/fs.js'
|
|
15
16
|
import * as git from '../host/git.js'
|
|
@@ -179,6 +180,55 @@ try {
|
|
|
179
180
|
const wsNone = await wsRouterUnavailable.methods.get('workspaces.list')({})
|
|
180
181
|
check('workspaces.list unavailable fallback', wsNone.available === false && wsNone.workspaces.length === 0)
|
|
181
182
|
|
|
183
|
+
console.log('float 平台分支纯函数')
|
|
184
|
+
const binRoot = '/plugin/desktop/float/bin'
|
|
185
|
+
const macArm = floatPlatform.floatBinaryCandidates('darwin', 'arm64', binRoot)
|
|
186
|
+
check('float binary candidates darwin arm64 顺序', macArm[0].endsWith('gufa-float-macos-arm64') && macArm[1].endsWith('gufa-float-macos-universal'), JSON.stringify(macArm))
|
|
187
|
+
const macX64 = floatPlatform.floatBinaryCandidates('darwin', 'x64', binRoot)
|
|
188
|
+
check('float binary candidates darwin x64 顺序', macX64[0].endsWith('gufa-float-macos-x64'), JSON.stringify(macX64))
|
|
189
|
+
const winBins = floatPlatform.floatBinaryCandidates('win32', 'x64', binRoot)
|
|
190
|
+
check('float binary candidates win32', winBins[0] === '/plugin/desktop/float/bin/win-x64/gufa-float-win.exe' && winBins[1].endsWith('gufa-float-win.exe'), JSON.stringify(winBins))
|
|
191
|
+
const linuxBins = floatPlatform.floatBinaryCandidates('linux', 'x64', binRoot)
|
|
192
|
+
check('float binary candidates linux', linuxBins[0] === '/plugin/desktop/float/bin/linux-x64/gufa-float-linux', JSON.stringify(linuxBins))
|
|
193
|
+
check('float binary candidates 未知平台为空', floatPlatform.floatBinaryCandidates('aix', 'x64', binRoot).length === 0)
|
|
194
|
+
|
|
195
|
+
const tasklistOut = [
|
|
196
|
+
'"gufa-float-win.exe","1234","Console","1","10,000 K"',
|
|
197
|
+
'"gufa-float-win.exe","5678","Console","1","10,000 K"',
|
|
198
|
+
'INFO: No tasks are running which match the specified criteria.',
|
|
199
|
+
'',
|
|
200
|
+
].join('\n')
|
|
201
|
+
check('parseTasklistPids 解析 CSV', JSON.stringify(floatPlatform.parseTasklistPids(tasklistOut)) === '[1234,5678]', JSON.stringify(floatPlatform.parseTasklistPids(tasklistOut)))
|
|
202
|
+
check('parseTasklistPids 空输入', floatPlatform.parseTasklistPids('').length === 0)
|
|
203
|
+
|
|
204
|
+
const psArray = JSON.stringify({ ok: true, accessibility: true, apps: [
|
|
205
|
+
{ pid: 10, owner: 'chrome', title: 'Chrome', bundleId: '', windowNumber: 1, frontmost: 0 },
|
|
206
|
+
{ pid: 11, owner: 'wechat', title: 'WeChat', bundleId: '', windowNumber: 2, frontmost: 1 },
|
|
207
|
+
] })
|
|
208
|
+
const psParsed = floatPlatform.parsePowerShellWindowList(psArray)
|
|
209
|
+
check('parsePowerShellWindowList 数组 + name 回填', psParsed !== null && psParsed.apps.length === 2 && psParsed.apps[0].name === 'chrome', JSON.stringify(psParsed))
|
|
210
|
+
const psSingle = floatPlatform.parsePowerShellWindowList(JSON.stringify({ ok: true, accessibility: true, apps: { pid: 12, owner: 'code', title: 'VS Code' } }))
|
|
211
|
+
check('parsePowerShellWindowList 单对象转数组', psSingle !== null && psSingle.apps.length === 1 && psSingle.apps[0].name === 'code', JSON.stringify(psSingle))
|
|
212
|
+
check('parsePowerShellWindowList ok:false', floatPlatform.parsePowerShellWindowList(JSON.stringify({ ok: false })) === null)
|
|
213
|
+
check('parsePowerShellWindowList 非法 JSON', floatPlatform.parsePowerShellWindowList('not-json') === null)
|
|
214
|
+
const psFiltered = floatPlatform.parsePowerShellWindowList(JSON.stringify({ ok: true, apps: [
|
|
215
|
+
{ pid: 1, owner: 'a', title: '' },
|
|
216
|
+
{ pid: 0, owner: 'b', title: 'B' },
|
|
217
|
+
{ pid: 2, owner: 'c', title: 'C' },
|
|
218
|
+
] }))
|
|
219
|
+
check('parsePowerShellWindowList 过滤空标题/非法 pid', psFiltered !== null && psFiltered.apps.length === 1 && psFiltered.apps[0].pid === 2, JSON.stringify(psFiltered))
|
|
220
|
+
|
|
221
|
+
const wmctrlOut = [
|
|
222
|
+
'0x03e00007 0 1234 host One Title With Spaces',
|
|
223
|
+
'0x03e00008 0 1234 host One Title With Spaces',
|
|
224
|
+
'0x03e00009 1 4321 host Another',
|
|
225
|
+
'malformed line',
|
|
226
|
+
].join('\n')
|
|
227
|
+
const wmApps = floatPlatform.parseWmctrlWindowList(wmctrlOut, (pid) => (pid === 1234 ? 'chrome' : 'wechat'))
|
|
228
|
+
check('parseWmctrlWindowList 解析/去重/owner', wmApps.length === 2 && wmApps[0].owner === 'chrome' && wmApps[0].title === 'One Title With Spaces' && wmApps[1].owner === 'wechat', JSON.stringify(wmApps))
|
|
229
|
+
const wmFallback = floatPlatform.parseWmctrlWindowList('0x1 0 999 host T', () => { throw new Error('gone') })
|
|
230
|
+
check('parseWmctrlWindowList comm 失败回退 pid', wmFallback.length === 1 && wmFallback[0].owner === '999', JSON.stringify(wmFallback))
|
|
231
|
+
|
|
182
232
|
console.log('ssh / assets / placeholders')
|
|
183
233
|
const sshHosts = await call(router, 'ssh.hosts')
|
|
184
234
|
check('ssh.hosts shape', Array.isArray(sshHosts.hosts))
|
package/src/client/20-editor.js
CHANGED
|
@@ -494,7 +494,7 @@
|
|
|
494
494
|
|
|
495
495
|
/* ── 组件 ───────────────────────────────────────────────────────────── */
|
|
496
496
|
|
|
497
|
-
|
|
497
|
+
function GufaEditorPaneComponent(props) {
|
|
498
498
|
const tabs = useMemo(() => (Array.isArray(props.tabs) ? props.tabs : []), [props.tabs])
|
|
499
499
|
const activePath = typeof props.activePath === 'string' ? props.activePath : null
|
|
500
500
|
const root = typeof props.root === 'string' ? props.root : ''
|
|
@@ -1347,6 +1347,56 @@
|
|
|
1347
1347
|
)
|
|
1348
1348
|
}
|
|
1349
1349
|
|
|
1350
|
+
/* 光标事件外部 store:App 不再为每次光标移动重渲染整个 IDE,状态栏订阅即可。 */
|
|
1351
|
+
G.cursorStore = (() => {
|
|
1352
|
+
const listeners = new Set()
|
|
1353
|
+
let value = null
|
|
1354
|
+
return {
|
|
1355
|
+
get: () => value,
|
|
1356
|
+
subscribe: (listener) => {
|
|
1357
|
+
listeners.add(listener)
|
|
1358
|
+
return () => listeners.delete(listener)
|
|
1359
|
+
},
|
|
1360
|
+
set: (next) => {
|
|
1361
|
+
if (value === next) return
|
|
1362
|
+
if (value !== null && next !== null &&
|
|
1363
|
+
value.path === next.path && value.line === next.line && value.column === next.column &&
|
|
1364
|
+
value.lineCount === next.lineCount && value.selectedText === next.selectedText) return
|
|
1365
|
+
value = next
|
|
1366
|
+
for (const listener of [...listeners]) {
|
|
1367
|
+
try {
|
|
1368
|
+
listener(next)
|
|
1369
|
+
} catch {
|
|
1370
|
+
/* 订阅者异常不影响编辑器 */
|
|
1371
|
+
}
|
|
1372
|
+
}
|
|
1373
|
+
},
|
|
1374
|
+
}
|
|
1375
|
+
})()
|
|
1376
|
+
G.useCursorStore = function useCursorStore() {
|
|
1377
|
+
const [snapshot, setSnapshot] = React.useState(G.cursorStore.get())
|
|
1378
|
+
React.useEffect(() => {
|
|
1379
|
+
setSnapshot(G.cursorStore.get())
|
|
1380
|
+
return G.cursorStore.subscribe(setSnapshot)
|
|
1381
|
+
}, [])
|
|
1382
|
+
return snapshot
|
|
1383
|
+
}
|
|
1384
|
+
/* 状态栏行数/光标:只订阅 cursorStore,光标移动不会触发 App 根组件重渲染。 */
|
|
1385
|
+
G.StatusCursor = function StatusCursor(props) {
|
|
1386
|
+
const activePath = props !== null && props !== undefined ? props.activePath : null
|
|
1387
|
+
const fallbackLineCount = props !== null && props !== undefined && Number.isFinite(props.fallbackLineCount) ? props.fallbackLineCount : 0
|
|
1388
|
+
const cursor = G.useCursorStore()
|
|
1389
|
+
const matched = cursor !== null && cursor.path === activePath
|
|
1390
|
+
const lineCount = matched && Number.isFinite(cursor.lineCount) ? cursor.lineCount : fallbackLineCount
|
|
1391
|
+
const cursorText = matched ? `${G.t('status.ln')} ${cursor.line},${G.t('status.col')} ${cursor.column}` : ''
|
|
1392
|
+
return React.createElement(React.Fragment, null,
|
|
1393
|
+
activePath !== null ? React.createElement('span', { className: 'gufa-status-item' }, `${lineCount} ${G.t('status.lines')}`) : null,
|
|
1394
|
+
cursorText !== '' ? React.createElement('span', { className: 'gufa-status-item' }, cursorText) : null,
|
|
1395
|
+
)
|
|
1396
|
+
}
|
|
1397
|
+
/* EditorPane 只在 props 真正变化时重渲染(光标移动不再穿透到 Monaco 外层)。 */
|
|
1398
|
+
G.EditorPane = typeof React.memo === 'function' ? React.memo(GufaEditorPaneComponent) : GufaEditorPaneComponent
|
|
1399
|
+
|
|
1350
1400
|
/* 纯函数/加载状态测试钩子:供 scripts/test-editor.mjs 在无浏览器环境下校验
|
|
1351
1401
|
* URI、光标推进、主题映射与 loader 失败降级 / 重试 / 单例注入。 */
|
|
1352
1402
|
G.EditorPane.internals = Object.freeze({
|
package/src/client/90-app.js
CHANGED
|
@@ -250,7 +250,15 @@ G.GufaApp = function GufaApp(props) {
|
|
|
250
250
|
const [banner, setBanner] = useState('')
|
|
251
251
|
const [tabs, setTabs] = useState([])
|
|
252
252
|
const [activePath, setActivePath] = useState(null)
|
|
253
|
-
|
|
253
|
+
/* 选区(给右侧 AI 用)单独更新;光标位置/行数走 G.cursorStore,避免每次按键重渲染整个 IDE。 */
|
|
254
|
+
const [selection, setSelection] = useState(null)
|
|
255
|
+
/* 编辑器内容缓冲:Monaco 每次按键只写这里,300ms 停顿后才同步进 tabs(保存/自动保存直接读缓冲)。 */
|
|
256
|
+
const editorBuffersRef = useRef(new Map())
|
|
257
|
+
const tabsRef = useRef([])
|
|
258
|
+
const flushTimerRef = useRef(null)
|
|
259
|
+
const selectionTimerRef = useRef(null)
|
|
260
|
+
const pendingSelectionRef = useRef(null)
|
|
261
|
+
const flushBuffersRef = useRef(null)
|
|
254
262
|
const [refreshToken, setRefreshToken] = useState(0)
|
|
255
263
|
const [gitRefreshToken, setGitRefreshToken] = useState(0)
|
|
256
264
|
const [sshRefreshToken, setSshRefreshToken] = useState(0)
|
|
@@ -273,6 +281,9 @@ G.GufaApp = function GufaApp(props) {
|
|
|
273
281
|
const [explorerWidth, explorerDrag] = G.useSplitter({ initial: 260, min: 190, max: 520, storageKey: 'gufa-code:w:explorer' })
|
|
274
282
|
const [chatWidth, chatDrag] = G.useSplitter({ initial: 430, min: 320, max: 780, axis: 'x', invert: true, storageKey: 'gufa-code:w:chat' })
|
|
275
283
|
const [terminalHeight, terminalDrag] = G.useSplitter({ initial: 230, min: 120, max: 560, axis: 'y', invert: true, storageKey: 'gufa-code:h:terminal' })
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
tabsRef.current = tabs
|
|
286
|
+
}, [tabs])
|
|
276
287
|
|
|
277
288
|
const patchUi = useCallback((patch) => {
|
|
278
289
|
setUi((current) => {
|
|
@@ -289,7 +300,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
289
300
|
writeJson(GUFA_LS.project, value?.root ?? null)
|
|
290
301
|
setTabs([])
|
|
291
302
|
setActivePath(null)
|
|
292
|
-
|
|
303
|
+
setSelection(null)
|
|
304
|
+
editorBuffersRef.current.clear()
|
|
305
|
+
if (flushTimerRef.current !== null) { window.clearTimeout(flushTimerRef.current); flushTimerRef.current = null }
|
|
306
|
+
G.cursorStore.set(null)
|
|
293
307
|
setGitStatus(null)
|
|
294
308
|
setRefreshToken((token) => token + 1)
|
|
295
309
|
setGitRefreshToken((token) => token + 1)
|
|
@@ -395,6 +409,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
395
409
|
/* ── 文件打开 / 保存 / 关闭 ─────────────────────────────────────────── */
|
|
396
410
|
const openFile = useCallback(async (path) => {
|
|
397
411
|
if (project === null) return
|
|
412
|
+
flushBuffersRef.current?.()
|
|
398
413
|
const existing = tabs.find((tab) => tab.path === path)
|
|
399
414
|
if (existing !== undefined) {
|
|
400
415
|
setActivePath(path)
|
|
@@ -417,6 +432,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
417
432
|
/* 原子恢复标签集合:按快照顺序、去重、最后激活指定文件(避免 openFile 并发产生重复标签) */
|
|
418
433
|
const applyTabs = useCallback(async (paths, active) => {
|
|
419
434
|
if (project === null || !Array.isArray(paths)) return
|
|
435
|
+
flushBuffersRef.current?.()
|
|
420
436
|
const docs = []
|
|
421
437
|
const seen = new Set()
|
|
422
438
|
for (const path of paths.slice(0, 12)) {
|
|
@@ -429,6 +445,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
429
445
|
/* 快照里的文件可能已被删除:忽略 */
|
|
430
446
|
}
|
|
431
447
|
}
|
|
448
|
+
editorBuffersRef.current.clear()
|
|
432
449
|
setTabs(docs)
|
|
433
450
|
const wanted = typeof active === 'string' && docs.some((doc) => doc.path === active) ? active : (docs.length > 0 ? docs[docs.length - 1].path : null)
|
|
434
451
|
setActivePath(wanted)
|
|
@@ -437,27 +454,85 @@ G.GufaApp = function GufaApp(props) {
|
|
|
437
454
|
const activeTab = useMemo(() => tabs.find((tab) => tab.path === activePath) ?? null, [tabs, activePath])
|
|
438
455
|
|
|
439
456
|
const patchTab = useCallback((path, patch) => {
|
|
440
|
-
setTabs((current) =>
|
|
457
|
+
setTabs((current) => {
|
|
458
|
+
const next = current.map((tab) => (tab.path === path ? { ...tab, ...patch } : tab))
|
|
459
|
+
tabsRef.current = next
|
|
460
|
+
return next
|
|
461
|
+
})
|
|
441
462
|
}, [])
|
|
442
463
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
)
|
|
464
|
+
/* 把缓冲内容写回 tabs(停顿 / 保存 / 切换标签时调用),不会在每次按键触发渲染。 */
|
|
465
|
+
const flushEditorBuffers = useCallback(() => {
|
|
466
|
+
const buffers = editorBuffersRef.current
|
|
467
|
+
if (buffers.size === 0) return
|
|
468
|
+
setTabs((current) => {
|
|
469
|
+
let changed = false
|
|
470
|
+
const next = current.map((tab) => {
|
|
471
|
+
if (tab === null || !buffers.has(tab.path)) return tab
|
|
472
|
+
const content = buffers.get(tab.path)
|
|
473
|
+
const dirty = content !== tab.savedContent
|
|
474
|
+
if (tab.content === content && tab.dirty === dirty) return tab
|
|
475
|
+
changed = true
|
|
476
|
+
return { ...tab, content, dirty }
|
|
477
|
+
})
|
|
478
|
+
if (!changed) return current
|
|
479
|
+
tabsRef.current = next
|
|
480
|
+
return next
|
|
481
|
+
})
|
|
447
482
|
}, [])
|
|
448
483
|
|
|
484
|
+
flushBuffersRef.current = flushEditorBuffers
|
|
485
|
+
|
|
486
|
+
const scheduleEditorFlush = useCallback(() => {
|
|
487
|
+
if (flushTimerRef.current !== null) window.clearTimeout(flushTimerRef.current)
|
|
488
|
+
flushTimerRef.current = window.setTimeout(() => {
|
|
489
|
+
flushTimerRef.current = null
|
|
490
|
+
flushEditorBuffers()
|
|
491
|
+
}, 300)
|
|
492
|
+
}, [flushEditorBuffers])
|
|
493
|
+
|
|
494
|
+
const changeFile = useCallback((path, content) => {
|
|
495
|
+
editorBuffersRef.current.set(path, content)
|
|
496
|
+
const tab = tabsRef.current.find((item) => item !== null && item.path === path)
|
|
497
|
+
if (tab !== undefined && tab.dirty !== (content !== tab.savedContent)) {
|
|
498
|
+
/* 只在「干净 ↔ 脏」变化时立刻更新标签圆点,避免每个按键重渲染整棵 IDE 树。 */
|
|
499
|
+
setTabs((current) => {
|
|
500
|
+
let changed = false
|
|
501
|
+
const next = current.map((item) => {
|
|
502
|
+
if (item === null || item.path !== path) return item
|
|
503
|
+
const dirty = content !== item.savedContent
|
|
504
|
+
if (item.dirty === dirty) return item
|
|
505
|
+
changed = true
|
|
506
|
+
return { ...item, dirty }
|
|
507
|
+
})
|
|
508
|
+
if (!changed) return current
|
|
509
|
+
tabsRef.current = next
|
|
510
|
+
return next
|
|
511
|
+
})
|
|
512
|
+
}
|
|
513
|
+
scheduleEditorFlush()
|
|
514
|
+
}, [scheduleEditorFlush])
|
|
515
|
+
|
|
449
516
|
const saveFile = useCallback(async (path) => {
|
|
450
517
|
if (project === null) return
|
|
451
|
-
const tab =
|
|
452
|
-
if (tab === undefined
|
|
518
|
+
const tab = tabsRef.current.find((item) => item !== null && item.path === path)
|
|
519
|
+
if (tab === undefined) return
|
|
520
|
+
/* 缓冲里可能有比 tabs 更新的内容(按键后 300ms 内保存/自动保存) */
|
|
521
|
+
const content = editorBuffersRef.current.has(path) ? editorBuffersRef.current.get(path) : tab.content
|
|
522
|
+
if (content === tab.savedContent) {
|
|
523
|
+
editorBuffersRef.current.delete(path)
|
|
524
|
+
if (tab.dirty === true) patchTab(path, { content, dirty: false })
|
|
525
|
+
return
|
|
526
|
+
}
|
|
453
527
|
try {
|
|
454
528
|
const result = await G.api('fs.write', {
|
|
455
529
|
root: project.root,
|
|
456
530
|
path: tab.path,
|
|
457
|
-
content
|
|
531
|
+
content,
|
|
458
532
|
expectedRevision: tab.revision,
|
|
459
533
|
})
|
|
460
|
-
|
|
534
|
+
editorBuffersRef.current.delete(path)
|
|
535
|
+
patchTab(path, { content, revision: result.revision, savedRevision: result.revision, savedContent: content, dirty: false, size: result.size })
|
|
461
536
|
setBanner('')
|
|
462
537
|
// 内容保存不改变目录结构:只刷新 Git 状态,不重载文件树(避免整页闪烁)
|
|
463
538
|
setGitRefreshToken((token) => token + 1)
|
|
@@ -466,7 +541,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
466
541
|
if (error.code === 'revision-conflict') setBanner(t('editor.saveConflict'))
|
|
467
542
|
else setBanner(G.errorText(error))
|
|
468
543
|
}
|
|
469
|
-
}, [project,
|
|
544
|
+
}, [project, patchTab, refreshGit, t])
|
|
470
545
|
|
|
471
546
|
/** 顶栏提示:错误常驻红色;成功用绿色 toast,1.2 秒后自动消失。 */
|
|
472
547
|
const successTimerRef = useRef(null)
|
|
@@ -492,6 +567,8 @@ G.GufaApp = function GufaApp(props) {
|
|
|
492
567
|
}, [])
|
|
493
568
|
|
|
494
569
|
const closeTab = useCallback((path) => {
|
|
570
|
+
editorBuffersRef.current.delete(path)
|
|
571
|
+
flushBuffersRef.current?.()
|
|
495
572
|
setTabs((current) => {
|
|
496
573
|
const next = current.filter((tab) => tab.path !== path)
|
|
497
574
|
if (activePath === path) {
|
|
@@ -1802,10 +1879,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
1802
1879
|
return { path: activeTab.path, content: activeTab.content ?? '', language: activeTab.language }
|
|
1803
1880
|
}, [activeTab])
|
|
1804
1881
|
|
|
1805
|
-
const selectionForChat = useMemo(() =>
|
|
1806
|
-
if (cursor === null || typeof cursor.selectedText !== 'string' || cursor.selectedText === '') return null
|
|
1807
|
-
return { text: cursor.selectedText, path: cursor.path, line: cursor.line, column: cursor.column }
|
|
1808
|
-
}, [cursor])
|
|
1882
|
+
const selectionForChat = useMemo(() => selection, [selection])
|
|
1809
1883
|
|
|
1810
1884
|
/* ── IDE 专属快捷键(参考 VS Code;经典模式下不生效) ──────────────── */
|
|
1811
1885
|
const editorFocusedRef = useRef(false)
|
|
@@ -2017,7 +2091,7 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2017
2091
|
role: 'tab',
|
|
2018
2092
|
tabIndex: 0,
|
|
2019
2093
|
title: tab.title !== undefined && tab.title !== null ? tab.title : tab.path,
|
|
2020
|
-
onClick: () =>
|
|
2094
|
+
onClick: () => handleSelectTab(tab.path),
|
|
2021
2095
|
onAuxClick: (event) => { if (event.button === 1) closeTabWithConfirm(tab.path) },
|
|
2022
2096
|
},
|
|
2023
2097
|
h(G.Icon, { name: 'file', size: 13 }),
|
|
@@ -2072,10 +2146,39 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2072
2146
|
)
|
|
2073
2147
|
: null
|
|
2074
2148
|
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
|
|
2149
|
+
const handleEditorCursor = useCallback((value) => {
|
|
2150
|
+
if (value === null || value === undefined) return
|
|
2151
|
+
/* 状态栏订阅 cursorStore,不再触发 App 根组件渲染 */
|
|
2152
|
+
G.cursorStore.set(value)
|
|
2153
|
+
const selectedText = typeof value.selectedText === 'string' ? value.selectedText : ''
|
|
2154
|
+
if (selectedText === '') {
|
|
2155
|
+
if (selectionTimerRef.current !== null) { window.clearTimeout(selectionTimerRef.current); selectionTimerRef.current = null }
|
|
2156
|
+
pendingSelectionRef.current = null
|
|
2157
|
+
setSelection((current) => (current === null ? current : null))
|
|
2158
|
+
return
|
|
2159
|
+
}
|
|
2160
|
+
pendingSelectionRef.current = { text: selectedText, path: value.path, line: value.line, column: value.column }
|
|
2161
|
+
if (selectionTimerRef.current !== null) return
|
|
2162
|
+
selectionTimerRef.current = window.setTimeout(() => {
|
|
2163
|
+
selectionTimerRef.current = null
|
|
2164
|
+
const latest = pendingSelectionRef.current
|
|
2165
|
+
if (latest === null) return
|
|
2166
|
+
setSelection((current) => {
|
|
2167
|
+
if (current !== null && current.text === latest.text && current.path === latest.path &&
|
|
2168
|
+
current.line === latest.line && current.column === latest.column) return current
|
|
2169
|
+
return latest
|
|
2170
|
+
})
|
|
2171
|
+
}, 180)
|
|
2172
|
+
}, [])
|
|
2173
|
+
const handleEditorSave = useCallback((path) => { void saveFile(path) }, [saveFile])
|
|
2174
|
+
const handleSelectTab = useCallback((path) => {
|
|
2175
|
+
flushBuffersRef.current?.()
|
|
2176
|
+
setActivePath(path)
|
|
2177
|
+
}, [])
|
|
2178
|
+
useEffect(() => () => {
|
|
2179
|
+
if (flushTimerRef.current !== null) { window.clearTimeout(flushTimerRef.current); flushTimerRef.current = null }
|
|
2180
|
+
if (selectionTimerRef.current !== null) { window.clearTimeout(selectionTimerRef.current); selectionTimerRef.current = null }
|
|
2181
|
+
}, [])
|
|
2079
2182
|
|
|
2080
2183
|
const statusBranch = project?.isGit === true && gitStatus?.branch ? gitStatus.branch : null
|
|
2081
2184
|
const lineCount = activeTab === null || activeTab.kind === 'graph' ? 0 : String(activeTab.content ?? '').split('\n').length
|
|
@@ -2270,12 +2373,12 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2270
2373
|
theme,
|
|
2271
2374
|
palette: solidPalette,
|
|
2272
2375
|
root: project?.root ?? '',
|
|
2273
|
-
onSelectTab:
|
|
2376
|
+
onSelectTab: handleSelectTab,
|
|
2274
2377
|
onCloseTab: closeTabWithConfirm,
|
|
2275
2378
|
onChange: changeFile,
|
|
2276
|
-
onSave:
|
|
2379
|
+
onSave: handleEditorSave,
|
|
2277
2380
|
backdropMode: backdropActive,
|
|
2278
|
-
onCursor:
|
|
2381
|
+
onCursor: handleEditorCursor,
|
|
2279
2382
|
}),
|
|
2280
2383
|
),
|
|
2281
2384
|
),
|
|
@@ -2348,11 +2451,10 @@ G.GufaApp = function GufaApp(props) {
|
|
|
2348
2451
|
: h('span', { className: 'gufa-status-item' }, t('status.noGit')),
|
|
2349
2452
|
h('div', { className: 'gufa-status-fill' }),
|
|
2350
2453
|
activeTab !== null ? h('span', { className: 'gufa-status-item' }, activeTab.title !== undefined && activeTab.title !== null ? activeTab.title : G.shortPath(activeTab.path, 56)) : null,
|
|
2351
|
-
activeTab !== null ? h('span', { className: 'gufa-status-item' }, `${lineCount} ${t('status.lines')}`) : null,
|
|
2352
2454
|
activeTab !== null && problems[activeTab.path] !== undefined
|
|
2353
2455
|
? h('span', { className: 'gufa-status-item', style: { color: problems[activeTab.path].errors > 0 ? '#f85149' : '#e5c07b' } }, `${problems[activeTab.path].errors} ✕ ${problems[activeTab.path].warnings} ⚠`)
|
|
2354
2456
|
: null,
|
|
2355
|
-
|
|
2457
|
+
h(G.StatusCursor, { activePath, fallbackLineCount: lineCount }),
|
|
2356
2458
|
activeTab !== null && activeTab.dirty === true ? h('span', { className: 'gufa-status-item', style: { color: 'var(--gufa-accent)' } }, t('status.dirty')) : null,
|
|
2357
2459
|
activeTab !== null && activeTab.dirty !== true ? h('span', { className: 'gufa-status-item' }, G.Icon ? h(G.Icon, { name: 'check', size: 11 }) : null, t('status.saved')) : null,
|
|
2358
2460
|
h('button', {
|