dsh-remote-vs 0.24.0 → 0.26.0
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.en.md +50 -16
- package/README.md +40 -15
- package/THIRD-PARTY-NOTICES.md +188 -0
- package/lib/client.js +6512 -77887
- package/lib/index.js +1461 -1024
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/CodeEditor.d.ts +25 -0
- package/lib/types/client/EditorPane.d.ts +16 -5
- package/lib/types/client/FloatingPlaceholder.d.ts +16 -5
- package/lib/types/client/RemoteEditorView.d.ts +13 -10
- package/lib/types/client/RemoteExplorer.d.ts +53 -0
- package/lib/types/client/RemoteRoot.d.ts +5 -5
- package/lib/types/client/TerminalSnippets.d.ts +36 -0
- package/lib/types/client/TerminalView.d.ts +1 -1
- package/lib/types/client/XTerm.d.ts +33 -0
- package/lib/types/client/api.d.ts +37 -2
- package/lib/types/client/changes/review-state.d.ts +19 -0
- package/lib/types/client/connection.d.ts +16 -0
- package/lib/types/client/editor-capability.d.ts +27 -0
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/request-gate.d.ts +110 -0
- package/lib/types/client/scm/DiffView.d.ts +45 -7
- package/lib/types/client/scm/actions.d.ts +31 -3
- package/lib/types/client/store.d.ts +112 -4
- package/lib/types/client/terminal-input.d.ts +23 -0
- package/lib/types/client/terminal-snippets.d.ts +86 -0
- package/lib/types/client/vsc/FindWidget.d.ts +6 -0
- package/lib/types/client/vsc/breadcrumb.d.ts +30 -0
- package/lib/types/client/vsc/change-marks.d.ts +16 -6
- package/lib/types/client/vsc/editor-caret.d.ts +32 -0
- package/lib/types/client/vsc/editor-keymap.d.ts +35 -1
- package/lib/types/client/vsc/editor-langs.d.ts +9 -0
- package/lib/types/client/vsc/editor-settings.d.ts +55 -0
- package/lib/types/client/vsc/image-preview.d.ts +36 -0
- package/lib/types/client/vsc/kit.d.ts +13 -0
- package/lib/types/client/vsc/save-shortcut.d.ts +21 -0
- package/lib/types/client/vsc/terminal-clipboard.d.ts +15 -0
- package/lib/types/client/vsc/terminal-line.d.ts +25 -0
- package/lib/types/client/vsc/terminal-links.d.ts +62 -0
- package/lib/types/client/vsc/terminal-theme.d.ts +48 -0
- package/lib/types/client/vsc/terminal-writer.d.ts +52 -0
- package/lib/types/forward.d.ts +12 -0
- package/lib/types/fs-ops.d.ts +42 -0
- package/lib/types/http.d.ts +2 -0
- package/lib/types/keygen.d.ts +9 -0
- package/lib/types/monitor.d.ts +8 -0
- package/lib/types/notices.d.ts +16 -1
- package/lib/types/p2/helper-rpc.d.ts +45 -0
- package/lib/types/pool.d.ts +25 -0
- package/lib/types/routes.d.ts +2 -0
- package/lib/types/store.d.ts +7 -0
- package/lib/types/terminal.d.ts +33 -1
- package/lib/types/view-settings.d.ts +5 -0
- package/lib/{worlds-B7gEDBzC.js → worlds-RG8K5eom.js} +113 -15
- package/package.json +2 -1
- package/src/client/CodeEditor.tsx +205 -10
- package/src/client/DirectoryFlow.tsx +16 -0
- package/src/client/DoctorPanel.tsx +70 -7
- package/src/client/EditorPane.tsx +545 -118
- package/src/client/FloatingPlaceholder.tsx +34 -5
- package/src/client/HostsView.tsx +12 -3
- package/src/client/RemoteDirectoryPicker.tsx +12 -0
- package/src/client/RemoteEditorView.tsx +14 -11
- package/src/client/RemoteExplorer.tsx +929 -40
- package/src/client/RemoteRoot.tsx +167 -147
- package/src/client/SearchView.tsx +8 -0
- package/src/client/TerminalSnippets.tsx +432 -0
- package/src/client/TerminalView.tsx +50 -1
- package/src/client/XTerm.tsx +228 -58
- package/src/client/api.ts +106 -13
- package/src/client/auto-open-remote.ts +11 -9
- package/src/client/changes/ChangesDock.tsx +188 -6
- package/src/client/changes/changes.css +10 -3
- package/src/client/changes/review-state.ts +34 -0
- package/src/client/connection.ts +29 -0
- package/src/client/downloads.ts +49 -4
- package/src/client/editor-capability.ts +42 -0
- package/src/client/i18n.ts +228 -12
- package/src/client/index.tsx +22 -6
- package/src/client/request-gate.ts +221 -0
- package/src/client/scm/CommitPane.tsx +20 -2
- package/src/client/scm/DiffView.tsx +343 -117
- package/src/client/scm/HistoryPanel.tsx +23 -2
- package/src/client/scm/RepoPicker.tsx +1 -1
- package/src/client/scm/ScmPanel.tsx +391 -87
- package/src/client/scm/actions.ts +95 -12
- package/src/client/store.tsx +537 -22
- package/src/client/terminal-input.ts +44 -0
- package/src/client/terminal-snippets.ts +216 -0
- package/src/client/ui.tsx +4 -0
- package/src/client/vsc/FindWidget.tsx +24 -9
- package/src/client/vsc/breadcrumb.tsx +339 -0
- package/src/client/vsc/change-marks.ts +93 -44
- package/src/client/vsc/editor-caret.ts +30 -0
- package/src/client/vsc/editor-keymap.ts +59 -1
- package/src/client/vsc/editor-langs.ts +20 -0
- package/src/client/vsc/editor-settings.ts +146 -0
- package/src/client/vsc/editor-theme.ts +4 -5
- package/src/client/vsc/file-icons.tsx +17 -3
- package/src/client/vsc/image-preview.tsx +110 -0
- package/src/client/vsc/kit.tsx +46 -10
- package/src/client/vsc/save-shortcut.ts +47 -1
- package/src/client/vsc/terminal-clipboard.ts +19 -0
- package/src/client/vsc/terminal-line.ts +101 -0
- package/src/client/vsc/terminal-links.ts +166 -0
- package/src/client/vsc/terminal-theme.ts +97 -0
- package/src/client/vsc/terminal-writer.ts +112 -0
- package/src/client/vsc/vsc.css +1078 -181
- package/src/forward.ts +47 -9
- package/src/fs-ops.ts +124 -4
- package/src/git-ops.ts +20 -3
- package/src/http.ts +35 -4
- package/src/keygen.ts +55 -4
- package/src/monitor.ts +13 -0
- package/src/notices.ts +23 -1
- package/src/p2/helper-rpc.ts +113 -7
- package/src/p2/worlds.ts +14 -1
- package/src/pool.ts +99 -27
- package/src/routes.ts +212 -43
- package/src/sftp.ts +51 -14
- package/src/store.ts +10 -0
- package/src/terminal.ts +225 -24
- package/src/view-settings.ts +50 -10
- package/lib/types/client/Dialog.d.ts +0 -14
- package/src/client/Dialog.tsx +0 -76
|
@@ -1,17 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The editor area: one tab strip for code files, previews and diffs, an info
|
|
3
|
-
* row, and the
|
|
3
|
+
* row, the body, and (in the full-width conversation-view variant) a status bar.
|
|
4
4
|
*
|
|
5
|
-
* The
|
|
6
|
-
*
|
|
7
|
-
* every
|
|
8
|
-
*
|
|
5
|
+
* The chrome follows the local sidebar plugin's editor (same tab strip, info
|
|
6
|
+
* row, empty states, status bar, image preview and editor background tokens),
|
|
7
|
+
* while every remote-only capability stays exactly where it was: the remote
|
|
8
|
+
* read/write routes, the save-conflict banner and its on-demand difference, the
|
|
9
|
+
* diff tabs, markdown/HTML previews, session change marks and the offline
|
|
10
|
+
* read-only degradation.
|
|
11
|
+
*
|
|
12
|
+
* Three variants share this component, chosen from the store's effective
|
|
13
|
+
* surface — never from a prop, so a surface can never mount two live buffers:
|
|
14
|
+
* - `sidebar`: the docked pane — a FULL-COLUMN rail page and the default seat
|
|
15
|
+
* (opening a file switches the rail to it; closing the last file switches
|
|
16
|
+
* back to the directory);
|
|
17
|
+
* - `center`: the conversation-view tab next to 对话 / 轨迹 (optional, full
|
|
18
|
+
* width, breadcrumb + status bar);
|
|
19
|
+
* - `float`: the frame-wide floating window (its own font zoom applies).
|
|
9
20
|
*/
|
|
10
|
-
import { useCallback, useEffect, useMemo, useRef, useState, type ReactNode } from 'react'
|
|
21
|
+
import { useCallback, useEffect, useMemo, useRef, useState, useSyncExternalStore, type CSSProperties, type ReactNode } from 'react'
|
|
11
22
|
import { api, fileReadTimeoutMs } from './api.ts'
|
|
12
23
|
import { clientDeadlineFor } from '../timeouts.ts'
|
|
13
24
|
import { diffText, type TextHunk } from '../changes/text-diff.ts'
|
|
14
|
-
import { CodeEditor, type CodeEditorHandle, type CodeEditorViewState } from './CodeEditor.tsx'
|
|
25
|
+
import { CodeEditor, type CodeEditorCaret, type CodeEditorHandle, type CodeEditorViewState } from './CodeEditor.tsx'
|
|
15
26
|
import { ConnectionStatusChip } from './ConnectionStatus.tsx'
|
|
16
27
|
import { isConnectionFailure, useConnectionStatus } from './connection.ts'
|
|
17
28
|
import { sameLocalDir } from './composer.ts'
|
|
@@ -23,12 +34,27 @@ import { Btn } from './ui.tsx'
|
|
|
23
34
|
import { renderMarkdown } from './vsc/markdown.tsx'
|
|
24
35
|
import { langLabel, langFromPath } from './vsc/tokenize.ts'
|
|
25
36
|
import { installSaveShortcut } from './vsc/save-shortcut.ts'
|
|
37
|
+
import { Breadcrumb } from './vsc/breadcrumb.tsx'
|
|
38
|
+
import { ImagePreview } from './vsc/image-preview.tsx'
|
|
39
|
+
import {
|
|
40
|
+
editorSettingsSnapshot,
|
|
41
|
+
stepFontSize,
|
|
42
|
+
subscribeEditorSettings,
|
|
43
|
+
updateEditorSettings,
|
|
44
|
+
type EditorSettings,
|
|
45
|
+
} from './vsc/editor-settings.ts'
|
|
46
|
+
import { detectIndentLabel } from './vsc/editor-langs.ts'
|
|
26
47
|
import {
|
|
27
48
|
IconButton,
|
|
28
49
|
IconClose,
|
|
50
|
+
IconCode,
|
|
51
|
+
IconCollapse,
|
|
29
52
|
IconDiff,
|
|
53
|
+
IconExpand,
|
|
54
|
+
IconFloat,
|
|
30
55
|
IconRefresh,
|
|
31
56
|
IconSave,
|
|
57
|
+
IconWrap,
|
|
32
58
|
MiniSpinner,
|
|
33
59
|
Segmented,
|
|
34
60
|
baseName,
|
|
@@ -112,7 +138,7 @@ function undoActionLabel(t: (key: string) => string, kind: 'add' | 'mod' | 'del'
|
|
|
112
138
|
|
|
113
139
|
/** Tab icon: diffs, images and text files each get their own glyph. */
|
|
114
140
|
function tabIcon(tab: { kind: string; image: boolean }): ReactNode {
|
|
115
|
-
if (tab.kind === 'diff') return <IconDiff size={
|
|
141
|
+
if (tab.kind === 'diff') return <IconDiff size={11} />
|
|
116
142
|
if (tab.image) return <span>▣</span>
|
|
117
143
|
return <span>▪</span>
|
|
118
144
|
}
|
|
@@ -172,9 +198,143 @@ function dropOversized(prev: Record<string, string>, keep: string | undefined):
|
|
|
172
198
|
return next
|
|
173
199
|
}
|
|
174
200
|
|
|
201
|
+
/**
|
|
202
|
+
* Cache key of one image PREVIEW: the path PLUS the tab's reload nonce.
|
|
203
|
+
*
|
|
204
|
+
* The base64 payload is a snapshot of one read. Keying by path alone kept
|
|
205
|
+
* painting the old bytes after a reload (and after a reconnect's background
|
|
206
|
+
* re-read of an inactive tab, which has no cache-clearing effect running); the
|
|
207
|
+
* nonce changes with every successful re-read, so a stale entry is simply never
|
|
208
|
+
* looked up again and ages out of the bounded cache.
|
|
209
|
+
*/
|
|
210
|
+
function imageCacheKey(tab: { fullPath: string; reloadNonce?: number }): string {
|
|
211
|
+
return `${tab.fullPath}@${tab.reloadNonce ?? 0}`
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/** Which chrome variant this mount renders (see the file header). */
|
|
215
|
+
type EditorVariant = 'sidebar' | 'center' | 'float'
|
|
216
|
+
|
|
217
|
+
/** React binding for the shared editor view preferences. */
|
|
218
|
+
function useEditorSettings(): EditorSettings {
|
|
219
|
+
return useSyncExternalStore(subscribeEditorSettings, editorSettingsSnapshot, editorSettingsSnapshot)
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** One status-bar entry. */
|
|
223
|
+
function StatusItem(props: { title?: string; error?: boolean; children: ReactNode; onClick?: () => void }): ReactNode {
|
|
224
|
+
const className = `rvs-status-item${props.error === true ? ' rvs-status-error' : ''}`
|
|
225
|
+
if (props.onClick === undefined) {
|
|
226
|
+
return <span className={className} title={props.title}>{props.children}</span>
|
|
227
|
+
}
|
|
228
|
+
return (
|
|
229
|
+
<button type="button" className={`${className} rvs-status-btn`} title={props.title} onClick={props.onClick}>
|
|
230
|
+
{props.children}
|
|
231
|
+
</button>
|
|
232
|
+
)
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Bottom status bar (full-width variant only, like the sidebar plugin).
|
|
237
|
+
*
|
|
238
|
+
* Left is "where am I" (language, line:column, selection size, indent); right is
|
|
239
|
+
* "how is it shown" (wrap, font size, save state) plus the file encoding. Wrap
|
|
240
|
+
* and font size are CLICKABLE on purpose: those are the two display switches a
|
|
241
|
+
* reader changes often, and making them hunt through a menu would be worse.
|
|
242
|
+
*/
|
|
243
|
+
function StatusBar(props: {
|
|
244
|
+
t: (key: string) => string
|
|
245
|
+
diff: boolean
|
|
246
|
+
caret: CodeEditorCaret | undefined
|
|
247
|
+
language: string
|
|
248
|
+
indent: string | undefined
|
|
249
|
+
wrap: boolean
|
|
250
|
+
fontSize: number
|
|
251
|
+
readOnly: boolean
|
|
252
|
+
dirty: boolean
|
|
253
|
+
loading: boolean
|
|
254
|
+
saving: boolean
|
|
255
|
+
error: string | undefined
|
|
256
|
+
}): ReactNode {
|
|
257
|
+
const caret = props.caret
|
|
258
|
+
const t = props.t
|
|
259
|
+
const saveLabel = props.loading
|
|
260
|
+
? t('common.loading')
|
|
261
|
+
: props.saving
|
|
262
|
+
? t('editor.statusSaving')
|
|
263
|
+
: props.dirty
|
|
264
|
+
? t('editor.unsaved')
|
|
265
|
+
: t('editor.statusClean')
|
|
266
|
+
return (
|
|
267
|
+
<div className="rvs-statusbar">
|
|
268
|
+
<div className="rvs-status-left">
|
|
269
|
+
{props.diff ? (
|
|
270
|
+
<>
|
|
271
|
+
<StatusItem title={t('editor.diffTitle')}>{t('editor.diffTitle')}</StatusItem>
|
|
272
|
+
<StatusItem title={t('editor.diffReadOnlyTitle')}>{t('editor.statusReadOnly')}</StatusItem>
|
|
273
|
+
</>
|
|
274
|
+
) : (
|
|
275
|
+
<>
|
|
276
|
+
<StatusItem title={t('editor.statusLanguage')}>{props.language}</StatusItem>
|
|
277
|
+
<StatusItem title={t('editor.statusPosition')}>
|
|
278
|
+
{t('editor.statusPositionValue')
|
|
279
|
+
.replace('{line}', String(caret?.line ?? 1))
|
|
280
|
+
.replace('{column}', String(caret?.column ?? 1))}
|
|
281
|
+
</StatusItem>
|
|
282
|
+
{caret !== undefined && caret.selected > 0 && (
|
|
283
|
+
<StatusItem title={t('editor.statusSelected')}>
|
|
284
|
+
{t('editor.statusSelectedValue').replace('{count}', String(caret.selected))}
|
|
285
|
+
</StatusItem>
|
|
286
|
+
)}
|
|
287
|
+
{props.indent !== undefined && <StatusItem title={t('editor.statusIndent')}>{props.indent}</StatusItem>}
|
|
288
|
+
</>
|
|
289
|
+
)}
|
|
290
|
+
</div>
|
|
291
|
+
<div className="rvs-status-right">
|
|
292
|
+
{props.error !== undefined && (
|
|
293
|
+
<StatusItem title={props.error} error>
|
|
294
|
+
{t('editor.statusError')}
|
|
295
|
+
</StatusItem>
|
|
296
|
+
)}
|
|
297
|
+
{props.diff ? null : (
|
|
298
|
+
<>
|
|
299
|
+
{props.readOnly && (
|
|
300
|
+
<StatusItem title={t('editor.statusReadOnlyTitle')}>{t('editor.statusReadOnly')}</StatusItem>
|
|
301
|
+
)}
|
|
302
|
+
<StatusItem
|
|
303
|
+
title={t('editor.statusWrapToggle')}
|
|
304
|
+
onClick={() => updateEditorSettings({ wrap: !props.wrap })}
|
|
305
|
+
>
|
|
306
|
+
{props.wrap ? t('editor.statusWrapOn') : t('editor.statusWrapOff')}
|
|
307
|
+
</StatusItem>
|
|
308
|
+
<StatusItem title={t('editor.statusFont')}>{`${props.fontSize}px`}</StatusItem>
|
|
309
|
+
<StatusItem title={t('editor.statusSaved')}>{saveLabel}</StatusItem>
|
|
310
|
+
</>
|
|
311
|
+
)}
|
|
312
|
+
<StatusItem title={t('editor.statusEncoding')}>UTF-8</StatusItem>
|
|
313
|
+
</div>
|
|
314
|
+
</div>
|
|
315
|
+
)
|
|
316
|
+
}
|
|
317
|
+
|
|
175
318
|
export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
176
319
|
const store = useExplorer()
|
|
177
320
|
const { t, tabs, activeTab, alias } = store
|
|
321
|
+
const settings = useEditorSettings()
|
|
322
|
+
/**
|
|
323
|
+
* Which chrome this mount renders. Derived from the store's EFFECTIVE surface
|
|
324
|
+
* (float wins over the base mount), never from a prop: the same component is
|
|
325
|
+
* mounted by the sidebar, the conversation view and the floating window, and
|
|
326
|
+
* exactly one of them may own the live buffer.
|
|
327
|
+
*/
|
|
328
|
+
const variant: EditorVariant = store.editorSurface === 'center'
|
|
329
|
+
? 'center'
|
|
330
|
+
: store.editorSurface === 'float' ? 'float' : 'sidebar'
|
|
331
|
+
const center = variant === 'center'
|
|
332
|
+
// The floating window owns its own Ctrl+wheel zoom (a property of the window,
|
|
333
|
+
// see FloatingEditorWindow), so the shared preference is set on the other two
|
|
334
|
+
// surfaces only.
|
|
335
|
+
const fontStyle = variant === 'float'
|
|
336
|
+
? undefined
|
|
337
|
+
: ({ '--rvs-editor-font-size': `${settings.fontSize}px` } as CSSProperties)
|
|
178
338
|
// Jump targets of the file on screen; empty when it carries no change data.
|
|
179
339
|
const changeHunks = activeTab?.changeSet?.hunks ?? []
|
|
180
340
|
const chat = useRemoteChatTarget(store.ctx)
|
|
@@ -194,6 +354,17 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
194
354
|
const connection = useConnectionStatus()
|
|
195
355
|
const offline = connection?.state === 'error'
|
|
196
356
|
|
|
357
|
+
/**
|
|
358
|
+
* The tab strip's roving focus stops, by tab id.
|
|
359
|
+
*
|
|
360
|
+
* The strip is ONE Tab stop (WAI-ARIA tabs): ←/→ and Home/End move the
|
|
361
|
+
* selection inside it, and only the active tab carries `tabIndex={0}`. A map
|
|
362
|
+
* (not refs on the elements) because the strip is rebuilt from the store on
|
|
363
|
+
* every render, and a keydown must be able to focus a SIBLING that is not the
|
|
364
|
+
* one it fired on.
|
|
365
|
+
*/
|
|
366
|
+
const tabElements = useRef(new Map<string, HTMLDivElement>())
|
|
367
|
+
|
|
197
368
|
// Image data URL cache, keyed by path (remote reads are not free). Bounded —
|
|
198
369
|
// see `rememberRecent` / `dropOversized`.
|
|
199
370
|
const [images, setImages] = useState<Record<string, string>>({})
|
|
@@ -208,6 +379,11 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
208
379
|
useEffect(() => {
|
|
209
380
|
setTokenCount(undefined)
|
|
210
381
|
}, [activeTab?.id])
|
|
382
|
+
/** Caret readout for the status bar; reset when the file changes. */
|
|
383
|
+
const [caret, setCaret] = useState<CodeEditorCaret | undefined>(undefined)
|
|
384
|
+
useEffect(() => {
|
|
385
|
+
setCaret(undefined)
|
|
386
|
+
}, [activeTab?.id])
|
|
211
387
|
/**
|
|
212
388
|
* The "see the difference" payload of a refused save.
|
|
213
389
|
*
|
|
@@ -231,20 +407,27 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
231
407
|
// (see the editor host below), so it cannot be gated wholesale.
|
|
232
408
|
if (props.visible === false) return
|
|
233
409
|
if (tab === undefined || !tab.image || alias === '') return
|
|
234
|
-
|
|
410
|
+
// A capped read has no decodable payload: skip the read entirely so a
|
|
411
|
+
// partial base64 never becomes a cached (undecodable) data URL. The
|
|
412
|
+
// "too large" notice is rendered from `truncated` instead.
|
|
413
|
+
if (tab.truncated) return
|
|
414
|
+
// Keyed by path + reload nonce, so a re-read shows the new bytes and a
|
|
415
|
+
// truncated read never caches a partial payload (see `imageCacheKey`).
|
|
416
|
+
const key = imageCacheKey(tab)
|
|
417
|
+
if (images[key] !== undefined || imageError[key] !== undefined) return
|
|
235
418
|
let cancelled = false
|
|
236
419
|
void (async () => {
|
|
237
420
|
try {
|
|
238
421
|
const read = await api.fileOp.read(alias, tab.fullPath)
|
|
239
422
|
if (cancelled) return
|
|
240
423
|
if (read.base64 === undefined) {
|
|
241
|
-
setImageError(prev => rememberRecent(prev,
|
|
424
|
+
setImageError(prev => rememberRecent(prev, key, t('editor.imageFailed')))
|
|
242
425
|
return
|
|
243
426
|
}
|
|
244
|
-
setImages(prev => rememberRecent(prev,
|
|
427
|
+
setImages(prev => rememberRecent(prev, key, `data:${mimeFor(tab.fullPath)};base64,${read.base64}`))
|
|
245
428
|
} catch (error) {
|
|
246
429
|
if (!cancelled) {
|
|
247
|
-
setImageError(prev => rememberRecent(prev,
|
|
430
|
+
setImageError(prev => rememberRecent(prev, key, error instanceof Error ? error.message : String(error)))
|
|
248
431
|
}
|
|
249
432
|
}
|
|
250
433
|
})()
|
|
@@ -257,8 +440,8 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
257
440
|
* instead of parking them until the page is reloaded.
|
|
258
441
|
*/
|
|
259
442
|
useEffect(() => {
|
|
260
|
-
setImages(prev => dropOversized(prev, activeTab
|
|
261
|
-
}, [activeTab?.fullPath])
|
|
443
|
+
setImages(prev => dropOversized(prev, activeTab === undefined ? undefined : imageCacheKey(activeTab)))
|
|
444
|
+
}, [activeTab?.fullPath, activeTab?.reloadNonce])
|
|
262
445
|
|
|
263
446
|
const closeWithGuard = async (tab: EditorTab): Promise<void> => {
|
|
264
447
|
if (tab.dirty) {
|
|
@@ -293,10 +476,23 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
293
476
|
await store.reloadTab(tab.id)
|
|
294
477
|
}
|
|
295
478
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
479
|
+
/**
|
|
480
|
+
* The preview inputs as STABLE primitives, not the tab object.
|
|
481
|
+
*
|
|
482
|
+
* `patchTab` builds a fresh tab object for every change (`dirty`, `saving`,
|
|
483
|
+
* `activeHunk`, `reloadNonce`…) while leaving `text` and the render-mode flags
|
|
484
|
+
* alone. Keying the two preview memos below on the tab therefore re-parsed a
|
|
485
|
+
* whole Markdown/HTML document whenever the user saved, jumped to a change or
|
|
486
|
+
* toggled a dot — a parse per action, for text that had not moved. A string's
|
|
487
|
+
* identity is stable while its contents are, so `text` + the flags is the key
|
|
488
|
+
* that actually means "the preview source changed".
|
|
489
|
+
*/
|
|
490
|
+
const previewText = activeTab?.text
|
|
491
|
+
const previewIsHtml = activeTab?.html === true
|
|
492
|
+
const previewIsMarkdown = activeTab?.markdown === true
|
|
493
|
+
const previewVisible = activeTab?.preview === true
|
|
494
|
+
|
|
495
|
+
const htmlDoc = useMemo(() => (previewIsHtml ? (previewText ?? '') : ''), [previewIsHtml, previewText])
|
|
300
496
|
|
|
301
497
|
/**
|
|
302
498
|
* The parsed Markdown preview.
|
|
@@ -305,20 +501,34 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
305
501
|
* re-parsed the whole document into a fresh element tree on EVERY store
|
|
306
502
|
* publish: this component subscribes to the store, so opening another file,
|
|
307
503
|
* saving, a git refresh or switching a panel all paid for a parse of text
|
|
308
|
-
* that had not changed. `renderMarkdown` is a pure function of the text,
|
|
309
|
-
* a
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
504
|
+
* that had not changed. `renderMarkdown` is a pure function of the text, so
|
|
505
|
+
* the memo key is the TEXT (a stable identity while the bytes are) plus the
|
|
506
|
+
* two mode flags — see `previewText` above for why the tab object is the wrong
|
|
507
|
+
* key. The guards keep the parse from happening at all for a file that is
|
|
508
|
+
* being read in source mode.
|
|
313
509
|
*/
|
|
314
510
|
const markdownPreview = useMemo(() => {
|
|
315
|
-
if (
|
|
316
|
-
return renderMarkdown(
|
|
511
|
+
if (!previewIsMarkdown || !previewVisible || previewText === undefined) return null
|
|
512
|
+
return renderMarkdown(previewText)
|
|
513
|
+
}, [previewIsMarkdown, previewVisible, previewText])
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* The status bar's indent hint, derived from the loaded text.
|
|
517
|
+
*
|
|
518
|
+
* Memoised on the tab: the status bar re-renders on every caret move, and
|
|
519
|
+
* scanning 200 lines per arrow key would be free in theory and wasteful in
|
|
520
|
+
* practice.
|
|
521
|
+
*/
|
|
522
|
+
const indentLabel = useMemo(() => {
|
|
523
|
+
if (activeTab === undefined || activeTab.kind !== 'file' || activeTab.binary) return undefined
|
|
524
|
+
return detectIndentLabel(activeTab.text)
|
|
317
525
|
}, [activeTab])
|
|
318
526
|
|
|
319
527
|
// The editor owns the live buffer; the save path pulls it imperatively
|
|
320
528
|
// instead of mirroring every keystroke into React state.
|
|
321
529
|
const editorRef = useRef<CodeEditorHandle>(null)
|
|
530
|
+
/** Editor body container: anchors the Ctrl+wheel zoom listener. */
|
|
531
|
+
const bodyRef = useRef<HTMLDivElement>(null)
|
|
322
532
|
|
|
323
533
|
/**
|
|
324
534
|
* Scroll + caret per tab, so re-selecting a tab returns to where it was.
|
|
@@ -407,6 +617,30 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
407
617
|
return registerLiveEditor(activeTab.id, () => editorRef.current)
|
|
408
618
|
}, [editorMounted, activeTab?.id])
|
|
409
619
|
|
|
620
|
+
/**
|
|
621
|
+
* Ctrl/Cmd + wheel changes the editor font size (same feel as the floating
|
|
622
|
+
* window's zoom).
|
|
623
|
+
*
|
|
624
|
+
* A native listener, not React's `onWheel`: React attaches its wheel handler
|
|
625
|
+
* as passive at the root, so `preventDefault()` is ignored and the page
|
|
626
|
+
* zooms instead. Scoped to the editor body, so the tree/terminal keep their
|
|
627
|
+
* own gestures.
|
|
628
|
+
*/
|
|
629
|
+
useEffect(() => {
|
|
630
|
+
const element = bodyRef.current
|
|
631
|
+
if (element === null) return
|
|
632
|
+
const onWheel = (event: WheelEvent): void => {
|
|
633
|
+
if (!(event.ctrlKey || event.metaKey)) return
|
|
634
|
+
event.preventDefault()
|
|
635
|
+
const direction = event.deltaY < 0 ? 1 : -1
|
|
636
|
+
updateEditorSettings({ fontSize: stepFontSize(editorSettingsSnapshot().fontSize, direction) })
|
|
637
|
+
}
|
|
638
|
+
element.addEventListener('wheel', onWheel, { passive: false })
|
|
639
|
+
return () => element.removeEventListener('wheel', onWheel)
|
|
640
|
+
// Re-attach when the body container appears (it does not exist in the empty
|
|
641
|
+
// state) so the first opened file still gets the zoom.
|
|
642
|
+
}, [tabs.length])
|
|
643
|
+
|
|
410
644
|
const saveActive = async (): Promise<void> => {
|
|
411
645
|
const tab = activeTab
|
|
412
646
|
if (tab === undefined) return
|
|
@@ -543,112 +777,269 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
543
777
|
}, [props.visible])
|
|
544
778
|
|
|
545
779
|
if (tabs.length === 0) {
|
|
780
|
+
if (center) {
|
|
781
|
+
return (
|
|
782
|
+
<div className="rvs-pane grow rvs-edge">
|
|
783
|
+
<div className="rvs-editor-empty">
|
|
784
|
+
<div className="rvs-editor-empty-glyph" aria-hidden="true">✎</div>
|
|
785
|
+
<div className="rvs-editor-empty-title">{t('editor.centerEmptyTitle')}</div>
|
|
786
|
+
<div className="rvs-editor-empty-hint">{t('editor.centerEmptyHint')}</div>
|
|
787
|
+
<div className="rvs-editor-empty-hint" style={{ opacity: 0.7 }}>{t('editor.emptyShortcuts')}</div>
|
|
788
|
+
</div>
|
|
789
|
+
</div>
|
|
790
|
+
)
|
|
791
|
+
}
|
|
546
792
|
return (
|
|
547
793
|
<div className="rvs-pane grow rvs-edge">
|
|
548
794
|
<div className="rvs-empty">
|
|
549
|
-
{t('editor.
|
|
550
|
-
<div
|
|
551
|
-
<span className="rvs-kbd">Ctrl</span> + <span className="rvs-kbd">S</span> {t('editor.saveHint')}
|
|
552
|
-
</div>
|
|
795
|
+
<div className="rvs-empty-title">{t('editor.dockEmptyTitle')}</div>
|
|
796
|
+
<div className="rvs-empty-hint">{t('editor.dockEmptyHint')}</div>
|
|
553
797
|
</div>
|
|
554
798
|
</div>
|
|
555
799
|
)
|
|
556
800
|
}
|
|
557
801
|
|
|
802
|
+
const isDiff = activeTab?.kind === 'diff'
|
|
803
|
+
/**
|
|
804
|
+
* Whether the "switch to content editing" action makes sense for this diff.
|
|
805
|
+
*
|
|
806
|
+
* A commit drill-down compares historical blobs; opening TODAY's file from it
|
|
807
|
+
* would read as editing the commit. A deletion has no content to edit (the
|
|
808
|
+
* read would just fail), and a binary diff has nothing an editor can show.
|
|
809
|
+
*/
|
|
810
|
+
const canSwitchToEdit = activeTab !== undefined
|
|
811
|
+
&& activeTab.kind === 'diff'
|
|
812
|
+
&& activeTab.ref === undefined
|
|
813
|
+
&& activeTab.diff !== undefined
|
|
814
|
+
&& !activeTab.diff.unsupported
|
|
815
|
+
&& !(activeTab.diff.newText === '' && activeTab.diff.oldText !== '')
|
|
816
|
+
const displayPath = activeTab?.fullPath ?? ''
|
|
817
|
+
const language = isDiff
|
|
818
|
+
? 'Diff'
|
|
819
|
+
: activeTab?.image === true ? 'Image' : langLabel(langFromPath(activeTab?.rel ?? ''))
|
|
820
|
+
const activeImageKey = activeTab === undefined ? undefined : imageCacheKey(activeTab)
|
|
821
|
+
const imageSrc = activeTab !== undefined && activeTab.image && activeImageKey !== undefined
|
|
822
|
+
? images[activeImageKey]
|
|
823
|
+
: undefined
|
|
824
|
+
const imageFailure = activeTab !== undefined && activeTab.image && activeImageKey !== undefined
|
|
825
|
+
? imageError[activeImageKey]
|
|
826
|
+
: undefined
|
|
827
|
+
|
|
558
828
|
return (
|
|
559
|
-
<div className="rvs-pane grow rvs-edge">
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
{
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
829
|
+
<div className="rvs-pane grow rvs-edge" style={fontStyle}>
|
|
830
|
+
{/* Tab strip: switch / close / dirty dot / diff glyph. Middle-click closes
|
|
831
|
+
too — the muscle memory shared with VS Code and browsers. */}
|
|
832
|
+
<div className="rvs-etabs" role="tablist" aria-label={t('editor.tabsLabel')}>
|
|
833
|
+
{tabs.map((tab, index) => {
|
|
834
|
+
const active = tab.id === store.activeTabId
|
|
835
|
+
const tabIsDiff = tab.kind === 'diff'
|
|
836
|
+
return (
|
|
837
|
+
<div
|
|
838
|
+
key={tab.id}
|
|
839
|
+
role="tab"
|
|
840
|
+
// Roving tabindex (WAI-ARIA tabs): the strip is one Tab stop, so
|
|
841
|
+
// the panel's other controls are not separated by N tab stops.
|
|
842
|
+
tabIndex={active ? 0 : -1}
|
|
843
|
+
aria-selected={active}
|
|
844
|
+
ref={(element) => {
|
|
845
|
+
if (element === null) tabElements.current.delete(tab.id)
|
|
846
|
+
else tabElements.current.set(tab.id, element)
|
|
847
|
+
}}
|
|
848
|
+
className={`rvs-etab${active ? ' active' : ''}${tabIsDiff ? ' rvs-etab-diff' : ''}`}
|
|
849
|
+
title={tabIsDiff ? `${tab.rel}${t('editor.diffSuffix')}` : tab.fullPath}
|
|
850
|
+
onClick={() => store.activateTab(tab.id)}
|
|
851
|
+
onAuxClick={(event) => {
|
|
852
|
+
if (event.button !== 1) return
|
|
853
|
+
event.preventDefault()
|
|
854
|
+
void closeWithGuard(tab)
|
|
855
|
+
}}
|
|
856
|
+
onKeyDown={(event) => {
|
|
857
|
+
// An IME composition owns Enter/Space (the candidate list).
|
|
858
|
+
if (event.nativeEvent.isComposing) return
|
|
859
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
860
|
+
event.preventDefault()
|
|
861
|
+
store.activateTab(tab.id)
|
|
862
|
+
return
|
|
863
|
+
}
|
|
864
|
+
// WAI-ARIA tabs keyboard model (audit I-16): arrows walk the
|
|
865
|
+
// strip, Home/End jump to its edges, wrapping at both ends, and
|
|
866
|
+
// the selection follows focus — the tabs are the cheap file
|
|
867
|
+
// switcher, so requiring Enter afterwards would only add a step.
|
|
868
|
+
const step = event.key === 'ArrowRight'
|
|
869
|
+
? 1
|
|
870
|
+
: event.key === 'ArrowLeft' ? -1 : undefined
|
|
871
|
+
if (step === undefined && event.key !== 'Home' && event.key !== 'End') return
|
|
872
|
+
event.preventDefault()
|
|
873
|
+
const next = event.key === 'Home'
|
|
874
|
+
? 0
|
|
875
|
+
: event.key === 'End'
|
|
876
|
+
? tabs.length - 1
|
|
877
|
+
: (index + (step ?? 0) + tabs.length) % tabs.length
|
|
878
|
+
const target = tabs[next]
|
|
879
|
+
if (target === undefined) return
|
|
880
|
+
store.activateTab(target.id)
|
|
881
|
+
tabElements.current.get(target.id)?.focus()
|
|
882
|
+
}}
|
|
585
883
|
>
|
|
586
|
-
<
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
884
|
+
<span className="rvs-etab-glyph">{tabIcon(tab)}</span>
|
|
885
|
+
<span className="rvs-etab-name">
|
|
886
|
+
{baseName(tab.rel)}
|
|
887
|
+
{tabIsDiff && <span style={{ opacity: .6 }}>{t('editor.diffSuffix')}</span>}
|
|
888
|
+
</span>
|
|
889
|
+
{tab.dirty && <span className="rvs-etab-dot" title={t('editor.unsaved')} />}
|
|
890
|
+
<button
|
|
891
|
+
type="button"
|
|
892
|
+
className="rvs-etab-close"
|
|
893
|
+
title={t('common.close')}
|
|
894
|
+
aria-label={t('common.close')}
|
|
895
|
+
onClick={(event) => { event.stopPropagation(); void closeWithGuard(tab) }}
|
|
896
|
+
>
|
|
897
|
+
<IconClose size={11} />
|
|
898
|
+
</button>
|
|
899
|
+
</div>
|
|
900
|
+
)
|
|
901
|
+
})}
|
|
590
902
|
</div>
|
|
903
|
+
|
|
591
904
|
{activeTab !== undefined && (
|
|
592
905
|
<>
|
|
906
|
+
{/* Info row: breadcrumb in the full-width variant (sibling picker),
|
|
907
|
+
single path line in the docked one. */}
|
|
593
908
|
<div className="rvs-einfo">
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
{
|
|
602
|
-
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
{tokenCount !== undefined && (
|
|
622
|
-
<span className="rvs-build" title={t('editor.tokenCount')}>tok {tokenCount}</span>
|
|
623
|
-
)}
|
|
624
|
-
{activeTab.kind === 'file' && (
|
|
625
|
-
<>
|
|
626
|
-
{/* The status chip used to be a four-deep nested ternary in
|
|
627
|
-
both the class and the label, while the project's own
|
|
628
|
-
review checklist forbids nested ternaries. One lookup per
|
|
629
|
-
concern instead. */}
|
|
630
|
-
<span className={`rvs-status ${tabStatusClass(activeTab)}`}>
|
|
631
|
-
{t(tabStatusKey(activeTab))}
|
|
909
|
+
{center && activeTab.kind === 'file'
|
|
910
|
+
? (
|
|
911
|
+
<Breadcrumb
|
|
912
|
+
t={t}
|
|
913
|
+
alias={alias}
|
|
914
|
+
root={store.root}
|
|
915
|
+
rootName={store.workspace?.name ?? ''}
|
|
916
|
+
path={displayPath}
|
|
917
|
+
onOpen={(fullPath) => { store.openFile(fullPath) }}
|
|
918
|
+
/>
|
|
919
|
+
)
|
|
920
|
+
: <span className="rvs-einfo-path" title={displayPath}>{displayPath}</span>}
|
|
921
|
+
<span className="rvs-einfo-actions">
|
|
922
|
+
{activeTab.kind === 'file' && (activeTab.markdown || activeTab.html) && (
|
|
923
|
+
<Segmented<'preview' | 'source'>
|
|
924
|
+
value={activeTab.preview ? 'preview' : 'source'}
|
|
925
|
+
onChange={(next) => store.updateTab(activeTab.id, { preview: next === 'preview' })}
|
|
926
|
+
options={[
|
|
927
|
+
{ id: 'preview', label: t('editor.preview') },
|
|
928
|
+
{ id: 'source', label: t('editor.source') },
|
|
929
|
+
]}
|
|
930
|
+
/>
|
|
931
|
+
)}
|
|
932
|
+
{activeTab.kind === 'diff' && (
|
|
933
|
+
<span style={{ color: 'var(--rvs-fg3)' }}>
|
|
934
|
+
{activeTab.staged && activeTab.ref === undefined ? t('scm.stagedReadonly') : ''}
|
|
935
|
+
{activeTab.ref !== undefined ? `${t('scm.commitDiff')} ${activeTab.ref.slice(0, 7)}` : ''}
|
|
632
936
|
</span>
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
937
|
+
)}
|
|
938
|
+
<span style={{ color: 'var(--rvs-fg3)' }}>{language}</span>
|
|
939
|
+
{/* Connection health sits where the build stamp does: it is the
|
|
940
|
+
surface the user is looking at while they work. */}
|
|
941
|
+
<ConnectionStatusChip compact />
|
|
942
|
+
{/* Build stamp + token count (see tsdown `define.__RVS_BUILD__`).
|
|
943
|
+
The GUI serves plugin bundles captured when `dsh web` started,
|
|
944
|
+
so the stamp says WHICH code is running, and the token count
|
|
945
|
+
says whether the grammar actually produced colored tokens. */}
|
|
946
|
+
<span className="rvs-build" title={`dsh-remote-vs build ${__RVS_BUILD__}`}>{__RVS_BUILD__}</span>
|
|
947
|
+
{tokenCount !== undefined && (
|
|
948
|
+
<span className="rvs-build" title={t('editor.tokenCount')}>tok {tokenCount}</span>
|
|
949
|
+
)}
|
|
950
|
+
{activeTab.kind === 'file' && (
|
|
951
|
+
<>
|
|
952
|
+
{/* The status chip used to be a four-deep nested ternary in
|
|
953
|
+
both the class and the label, while the project's own
|
|
954
|
+
review checklist forbids nested ternaries. One lookup per
|
|
955
|
+
concern instead. */}
|
|
956
|
+
<span className={`rvs-status ${tabStatusClass(activeTab)}`}>
|
|
957
|
+
{t(tabStatusKey(activeTab))}
|
|
958
|
+
</span>
|
|
959
|
+
<IconButton title={t('editor.reloadFile')} onClick={() => { void reloadWithGuard(activeTab) }} disabled={offline || activeTab.loading}>
|
|
960
|
+
<IconRefresh size={13} />
|
|
961
|
+
</IconButton>
|
|
962
|
+
<IconButton
|
|
963
|
+
title={`${t('editor.save')} (Ctrl+S)`}
|
|
964
|
+
onClick={() => { void saveActive() }}
|
|
965
|
+
disabled={offline || activeTab.loading || activeTab.binary || activeTab.truncated || !activeTab.dirty}
|
|
966
|
+
>
|
|
967
|
+
<IconSave size={13} />
|
|
968
|
+
</IconButton>
|
|
969
|
+
</>
|
|
970
|
+
)}
|
|
971
|
+
{activeTab.kind === 'diff' && (
|
|
972
|
+
<>
|
|
973
|
+
<IconButton title={t('scm.reloadDiff')} onClick={() => { void reloadWithGuard(activeTab) }} disabled={offline}>
|
|
974
|
+
<IconRefresh size={13} />
|
|
975
|
+
</IconButton>
|
|
976
|
+
{/* A diff is a view of a file, not a place to edit: this opens
|
|
977
|
+
the same path as a normal content tab, next to where the
|
|
978
|
+
save button lives for file tabs. Commit drills (historical
|
|
979
|
+
blobs), deletions and binary diffs are left out. */}
|
|
980
|
+
{canSwitchToEdit && (
|
|
981
|
+
<IconButton
|
|
982
|
+
title={t('editor.switchToEdit')}
|
|
983
|
+
onClick={() => { store.openFile(activeTab.fullPath) }}
|
|
984
|
+
>
|
|
985
|
+
<IconCode size={13} />
|
|
986
|
+
</IconButton>
|
|
987
|
+
)}
|
|
988
|
+
</>
|
|
989
|
+
)}
|
|
990
|
+
{activeTab.kind === 'file' && !activeTab.image && !activeTab.binary && (
|
|
636
991
|
<IconButton
|
|
637
|
-
title={
|
|
638
|
-
onClick={() => {
|
|
639
|
-
disabled={offline || activeTab.loading || activeTab.binary || activeTab.truncated || !activeTab.dirty}
|
|
992
|
+
title={t('editor.wrap')}
|
|
993
|
+
onClick={() => updateEditorSettings({ wrap: !settings.wrap })}
|
|
640
994
|
>
|
|
641
|
-
<
|
|
995
|
+
<IconWrap size={13} />
|
|
642
996
|
</IconButton>
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
997
|
+
)}
|
|
998
|
+
<span className="rvs-einfo-actions-divider" aria-hidden="true" />
|
|
999
|
+
{/* The floating window owns its OWN Ctrl+wheel zoom (a property of
|
|
1000
|
+
that window, persisted per window): the shared preference is not
|
|
1001
|
+
what paints there, so these two would look dead inside it. */}
|
|
1002
|
+
{variant !== 'float' && (
|
|
1003
|
+
<>
|
|
1004
|
+
<IconButton
|
|
1005
|
+
title={t('editor.fontSmaller')}
|
|
1006
|
+
onClick={() => updateEditorSettings({ fontSize: stepFontSize(settings.fontSize, -1) })}
|
|
1007
|
+
>
|
|
1008
|
+
<span className="rvs-font-glyph">A−</span>
|
|
1009
|
+
</IconButton>
|
|
1010
|
+
<IconButton
|
|
1011
|
+
title={t('editor.fontLarger')}
|
|
1012
|
+
onClick={() => updateEditorSettings({ fontSize: stepFontSize(settings.fontSize, 1) })}
|
|
1013
|
+
>
|
|
1014
|
+
<span className="rvs-font-glyph">A+</span>
|
|
1015
|
+
</IconButton>
|
|
1016
|
+
</>
|
|
1017
|
+
)}
|
|
1018
|
+
{variant !== 'float' && (
|
|
1019
|
+
<IconButton title={t('float.title')} onClick={() => { store.openFloatingEditor() }}>
|
|
1020
|
+
<IconFloat size={13} />
|
|
1021
|
+
</IconButton>
|
|
1022
|
+
)}
|
|
1023
|
+
{/* Same editor, another surface. One instance only: flipping the
|
|
1024
|
+
store's surface unmounts this mount and the target one takes
|
|
1025
|
+
the same buffer over (see the file header). */}
|
|
1026
|
+
{variant === 'center'
|
|
1027
|
+
? (
|
|
1028
|
+
<IconButton title={t('editor.dockToSidebar')} onClick={() => { store.dockEditorSidebar() }}>
|
|
1029
|
+
<IconCollapse size={13} />
|
|
1030
|
+
</IconButton>
|
|
1031
|
+
)
|
|
1032
|
+
: variant === 'sidebar'
|
|
1033
|
+
? (
|
|
1034
|
+
<IconButton title={t('editor.openInCenter')} onClick={() => { store.openEditorInCenter() }}>
|
|
1035
|
+
<IconExpand size={13} />
|
|
1036
|
+
</IconButton>
|
|
1037
|
+
)
|
|
1038
|
+
: null}
|
|
1039
|
+
</span>
|
|
650
1040
|
</div>
|
|
651
|
-
|
|
1041
|
+
|
|
1042
|
+
<div className="rvs-body" ref={bodyRef}>
|
|
652
1043
|
{/*
|
|
653
1044
|
A REFUSED save: the remote file moved on, so nothing was written.
|
|
654
1045
|
This sits above the buffer (not in a toast) because it is a
|
|
@@ -747,14 +1138,30 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
747
1138
|
)}
|
|
748
1139
|
{!activeTab.loading && activeTab.error === undefined && activeTab.kind === 'file' && (
|
|
749
1140
|
<>
|
|
750
|
-
{
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
1141
|
+
{/* A capped read has no decodable payload: the preview component
|
|
1142
|
+
turns that into a "too large" notice instead of the browser's
|
|
1143
|
+
broken-image icon, so it is mounted for every image tab. */}
|
|
1144
|
+
{activeTab.image && (imageSrc !== undefined || activeTab.truncated) && (
|
|
1145
|
+
<ImagePreview
|
|
1146
|
+
src={imageSrc ?? ''}
|
|
1147
|
+
path={activeTab.rel}
|
|
1148
|
+
size={activeTab.remoteSize ?? 0}
|
|
1149
|
+
{...(activeTab.truncated ? { truncated: true } : {})}
|
|
1150
|
+
t={t}
|
|
1151
|
+
/>
|
|
1152
|
+
)}
|
|
1153
|
+
{activeTab.image && imageSrc === undefined && !activeTab.truncated && (
|
|
1154
|
+
<div className="rvs-editor-notice">
|
|
1155
|
+
<div>{imageFailure ?? t('common.loading')}</div>
|
|
1156
|
+
</div>
|
|
1157
|
+
)}
|
|
1158
|
+
{!activeTab.image && activeTab.binary && (
|
|
1159
|
+
<div className="rvs-editor-notice">
|
|
1160
|
+
<div className="rvs-editor-notice-title">{t('editor.binaryTitle')}</div>
|
|
1161
|
+
<div>{activeTab.rel}</div>
|
|
1162
|
+
<div>{t('editor.binary')}</div>
|
|
755
1163
|
</div>
|
|
756
1164
|
)}
|
|
757
|
-
{!activeTab.image && activeTab.binary && <div className="rvs-empty">{t('editor.binary')}</div>}
|
|
758
1165
|
{!activeTab.image && !activeTab.binary && activeTab.markdown && activeTab.preview && markdownPreview}
|
|
759
1166
|
{!activeTab.image && !activeTab.binary && activeTab.html && activeTab.preview && (
|
|
760
1167
|
<iframe className="rvs-html-frame" title={activeTab.rel} sandbox="allow-same-origin" srcDoc={htmlDoc} />
|
|
@@ -782,6 +1189,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
782
1189
|
tabId={activeTab.id}
|
|
783
1190
|
readOnly={activeTab.truncated || offline}
|
|
784
1191
|
visible={props.visible}
|
|
1192
|
+
wrap={settings.wrap}
|
|
785
1193
|
ctx={store.ctx}
|
|
786
1194
|
sessionId={chat.sessionId}
|
|
787
1195
|
remoteRoot={store.repoRoot ?? store.root}
|
|
@@ -796,6 +1204,7 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
796
1204
|
? {}
|
|
797
1205
|
: { viewState: editorViewStateOf(activeTab.id) })}
|
|
798
1206
|
onTokens={setTokenCount}
|
|
1207
|
+
onCaretChange={setCaret}
|
|
799
1208
|
onViewState={rememberViewState}
|
|
800
1209
|
onStepHunk={(dir) => { gotoChange(activeTab.id, dir) }}
|
|
801
1210
|
onChangeStale={() => { markChangeStale(activeTab.id) }}
|
|
@@ -810,6 +1219,24 @@ export function EditorPane(props: { visible: boolean }): ReactNode {
|
|
|
810
1219
|
</>
|
|
811
1220
|
)}
|
|
812
1221
|
</div>
|
|
1222
|
+
|
|
1223
|
+
{/* Status bar: full-width variant only, matching the reference editor. */}
|
|
1224
|
+
{center && (
|
|
1225
|
+
<StatusBar
|
|
1226
|
+
t={t}
|
|
1227
|
+
diff={isDiff}
|
|
1228
|
+
caret={caret}
|
|
1229
|
+
language={language}
|
|
1230
|
+
indent={indentLabel}
|
|
1231
|
+
wrap={settings.wrap}
|
|
1232
|
+
fontSize={settings.fontSize}
|
|
1233
|
+
readOnly={activeTab.kind === 'file' && (activeTab.binary || activeTab.truncated || offline)}
|
|
1234
|
+
dirty={activeTab.dirty}
|
|
1235
|
+
loading={activeTab.loading}
|
|
1236
|
+
saving={activeTab.saving}
|
|
1237
|
+
error={activeTab.error}
|
|
1238
|
+
/>
|
|
1239
|
+
)}
|
|
813
1240
|
</>
|
|
814
1241
|
)}
|
|
815
1242
|
</div>
|