dsh-remote-vs 0.19.1 → 0.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,13 +11,14 @@ import { createPortal } from 'react-dom'
11
11
  import type { Context } from '@deepseek-ai/cordis'
12
12
  import { EditorSelection, EditorState, StateEffect, StateField, Compartment, type Extension, type Text } from '@codemirror/state'
13
13
  import { Decoration, EditorView, highlightActiveLine, keymap, lineNumbers, type DecorationSet } from '@codemirror/view'
14
- import { defaultKeymap, history, historyKeymap } from '@codemirror/commands'
14
+ import { history } from '@codemirror/commands'
15
15
  import { bracketMatching, ensureSyntaxTree, indentOnInput } from '@codemirror/language'
16
16
  import { closeBrackets } from '@codemirror/autocomplete'
17
17
  import { search } from '@codemirror/search'
18
18
  import { syntaxHighlighting } from '@codemirror/language'
19
19
  import { vscodeHighlightStyle } from './vsc/editor-palette.ts'
20
20
  import { FindWidget, clearFindMarks, findMatchHighlight, stepFind } from './vsc/FindWidget.tsx'
21
+ import { editorKeymap } from './vsc/editor-keymap.ts'
21
22
  import { javascript } from '@codemirror/lang-javascript'
22
23
  import { python } from '@codemirror/lang-python'
23
24
  import { json } from '@codemirror/lang-json'
@@ -587,72 +588,33 @@ export const CodeEditor = forwardRef<CodeEditorHandle, {
587
588
  if (host === null) return
588
589
  const extensions: Extension[] = [
589
590
  history(),
590
- keymap.of([
591
- ...defaultKeymap,
592
- ...historyKeymap,
593
- { key: 'Mod-s', run: () => { propsRef.current.onSave(); return true }, preventDefault: true },
594
- // Ctrl/Cmd+F opens OUR widget (the built-in search panel is never
595
- // mounted, so `searchKeymap` is deliberately absent). A selection seeds
596
- // the query, the way it does in VS Code, so find-on-selection is one
597
- // keystroke instead of a copy-paste.
598
- {
599
- key: 'Mod-f',
600
- run: (view) => {
601
- const sel = view.state.selection.main
602
- if (!sel.empty) {
603
- const text = view.state.sliceDoc(sel.from, sel.to)
604
- if (text !== '' && text.length <= 200) {
605
- setFindSeed(prev => ({ text, id: prev.id + 1 }))
606
- }
591
+ keymap.of(editorKeymap({
592
+ save: () => { propsRef.current.onSave() },
593
+ openFindForSelection: (view) => {
594
+ const sel = view.state.selection.main
595
+ if (!sel.empty) {
596
+ const text = view.state.sliceDoc(sel.from, sel.to)
597
+ if (text !== '' && text.length <= 200) {
598
+ setFindSeed(prev => ({ text, id: prev.id + 1 }))
607
599
  }
608
- setFindOpen(true)
609
- return true
610
- },
611
- preventDefault: true,
600
+ }
601
+ setFindOpen(true)
612
602
  },
613
- { key: 'F3', run: (view) => { stepFind(view, true); return true }, preventDefault: true },
614
- { key: 'Shift-F3', run: (view) => { stepFind(view, false); return true }, preventDefault: true },
615
- /**
616
- * 上一个 / 下一个改动点。
617
- *
618
- * `Mod-Shift-Alt-ArrowUp/Down` 是挑出来的空位:`@codemirror/commands` 的
619
- * defaultKeymap 里 `Mod-Alt-ArrowUp/Down`(多光标)、`Alt-ArrowUp/Down`
620
- * (移动行)、`Shift-Alt-ArrowUp/Down`(复制行)都被占了,三者之上再加
621
- * Shift 的这两个组合它没有用;浏览器侧 Ctrl+Shift+Alt+方向键也没有默认
622
- * 行为(选中/滚动都落在更低的组合上)。
623
- *
624
- * 没有 `onStepHunk`(面板没开)时返回 false,按键照旧落回 CodeMirror 的
625
- * 默认处理,不会平白吞掉一个组合键。
626
- */
627
- {
628
- key: 'Mod-Shift-Alt-ArrowDown',
629
- run: () => {
630
- const step = propsRef.current.onStepHunk
631
- if (step === undefined) return false
632
- step(1)
633
- return true
634
- },
635
- preventDefault: true,
603
+ stepFind: (view, forward) => {
604
+ stepFind(view, forward)
636
605
  },
637
- {
638
- key: 'Mod-Shift-Alt-ArrowUp',
639
- run: () => {
640
- const step = propsRef.current.onStepHunk
641
- if (step === undefined) return false
642
- step(-1)
643
- return true
644
- },
645
- preventDefault: true,
606
+ stepHunk: (delta) => {
607
+ const step = propsRef.current.onStepHunk
608
+ if (step === undefined) return false
609
+ step(delta)
610
+ return true
646
611
  },
647
- {
648
- key: 'Escape',
649
- run: () => {
650
- if (!findOpenRef.current) return false
651
- setFindOpen(false)
652
- return true
653
- },
612
+ closeFind: () => {
613
+ if (!findOpenRef.current) return false
614
+ setFindOpen(false)
615
+ return true
654
616
  },
655
- ]),
617
+ })),
656
618
  lineNumbers(),
657
619
  highlightActiveLine(),
658
620
  indentOnInput(),
@@ -32,8 +32,8 @@ import {
32
32
  IconRefresh,
33
33
  IconUpload,
34
34
  ContextMenu,
35
- FileIcon,
36
- FolderIcon,
35
+ ExplorerFileIcon,
36
+ ExplorerFolderIcon,
37
37
  baseName,
38
38
  confirmDialog,
39
39
  copyText,
@@ -566,8 +566,8 @@ export const ExplorerRowView = memo(function ExplorerRowView(props: ExplorerRowP
566
566
  >
567
567
  <span className="rvs-node-icon">
568
568
  {entry.isDir
569
- ? <FolderIcon path={entry.path} open={isOpen} size={15} />
570
- : <FileIcon path={entry.path} size={15} />}
569
+ ? <ExplorerFolderIcon path={entry.path} open={isOpen} size={16} />
570
+ : <ExplorerFileIcon path={entry.path} size={16} />}
571
571
  </span>
572
572
  {isRenaming
573
573
  ? (
@@ -2229,8 +2229,12 @@ export function RemoteExplorer(props: { showHidden: boolean; onToggleHidden: ()
2229
2229
  kind={row.createKind}
2230
2230
  onCommit={(value) => { void doCreate(value) }}
2231
2231
  onCancel={() => setCreating(undefined)}
2232
- fileIcon={<FileIcon path="name.ts" size={15} />}
2233
- folderIcon={<FolderIcon path="name" open={false} size={15} />}
2232
+ // 16 px to match the tree rows and the local sidebar's tree, and
2233
+ // a nameless sheet for the file: the row has no path yet, so
2234
+ // claiming a type (the old hard-coded `name.ts`) would paint
2235
+ // every "new file" row TS-blue.
2236
+ fileIcon={<ExplorerFileIcon path="untitled" size={16} />}
2237
+ folderIcon={<ExplorerFolderIcon path="name" open={false} size={16} />}
2234
2238
  t={t}
2235
2239
  />
2236
2240
  )
@@ -73,7 +73,7 @@ const zh: Record<string, string> = {
73
73
  'tab.terminal': '终端',
74
74
  'tab.ports': '端口',
75
75
  'tab.monitor': '监控',
76
- 'tab.remote': '远程',
76
+ 'tab.remote': '远程工作台',
77
77
  'tab.remoteDesc': '远端文件、终端与 Git',
78
78
  'hosts.title': '远程主机',
79
79
  'hosts.empty': '尚未配置主机。点击「新增主机」,或从现有配置导入。',
@@ -240,8 +240,8 @@ const zh: Record<string, string> = {
240
240
  'settings.hosts': '远程主机',
241
241
  'settings.workspaces': '远程工作区',
242
242
  'plugin.version': '插件版本',
243
- 'native.tab': '远程',
244
- 'native.guide.title': '远程',
243
+ 'native.tab': '远程工作台',
244
+ 'native.guide.title': '远程工作台',
245
245
  'native.guide.desc': '远端文件、终端与 Git',
246
246
  // ---- VS Code-style explorer (rail, tree, SCM, diff, history, editor)
247
247
  'tab.search': '搜索',
@@ -688,7 +688,7 @@ const en: Record<string, string> = {
688
688
  'tab.terminal': 'Terminal',
689
689
  'tab.ports': 'Ports',
690
690
  'tab.monitor': 'Monitor',
691
- 'tab.remote': 'Remote',
691
+ 'tab.remote': 'Remote Workspace',
692
692
  'tab.remoteDesc': 'Remote files, terminal and Git',
693
693
  'hosts.title': 'Remote hosts',
694
694
  'hosts.empty': 'No hosts yet. Add one, or import from existing configs.',
@@ -855,8 +855,8 @@ const en: Record<string, string> = {
855
855
  'settings.hosts': 'Remote hosts',
856
856
  'settings.workspaces': 'Remote workspaces',
857
857
  'plugin.version': 'Plugin version',
858
- 'native.tab': 'Remote',
859
- 'native.guide.title': 'Remote',
858
+ 'native.tab': 'Remote Workspace',
859
+ 'native.guide.title': 'Remote Workspace',
860
860
  'native.guide.desc': 'Remote files, terminal and Git',
861
861
  // ---- VS Code-style explorer
862
862
  'tab.search': 'Search',
@@ -83,9 +83,11 @@ export function apply(ctx: Context): void {
83
83
  return false
84
84
  }
85
85
  if (sidebar === undefined) return false
86
- // The host icon classifier paints the remote tree with the same glyphs
87
- // the local sidebar uses (and honours any registered icon theme). It is
88
- // optional: without it the built-in SVG set takes over.
86
+ // Optional host icon classifier: a better-sidebar release may publish
87
+ // `fileIcon` / `folderIcon` alongside `registerTab`, and then the remote
88
+ // tree follows the user's registered icon theme. The local sidebar plugin
89
+ // this one usually runs next to publishes none, so in practice the
90
+ // built-in colour set in `vsc/file-icons.tsx` is what paints the tree.
89
91
  try {
90
92
  const candidate = sidebar as unknown as Partial<IconServiceLike>
91
93
  if (typeof candidate.fileIcon === 'function' && typeof candidate.folderIcon === 'function') {
@@ -0,0 +1,97 @@
1
+ /**
2
+ * The editor's key bindings, in one testable place.
3
+ *
4
+ * Why this module exists
5
+ * ----------------------
6
+ * Bug (2026-11-10, user report): "the remote editor cannot input Tab".
7
+ *
8
+ * CodeMirror 6's `defaultKeymap` deliberately does NOT bind Tab — the browser
9
+ * default (move focus) stays available for accessibility. Indentation is the
10
+ * opt-in `indentWithTab` binding, and this plugin never added it, so Tab fell
11
+ * through to the browser: the caret left the editor instead of indenting. The
12
+ * local sidebar editor binds it, which is why the same key worked there.
13
+ *
14
+ * The binding list used to live inline inside the CodeMirror mount effect, which
15
+ * meant the only way to test it was to render the whole component. It lives here
16
+ * so `scripts/check-editor-tab.mjs` can mount a real CodeMirror with the REAL
17
+ * binding list and dispatch real Tab/Shift-Tab presses.
18
+ *
19
+ * Handlers are injected (no React, no editor state): the component wires them to
20
+ * its refs/stores.
21
+ */
22
+ import type { EditorView, KeyBinding } from '@codemirror/view'
23
+ import { defaultKeymap, historyKeymap, indentWithTab } from '@codemirror/commands'
24
+
25
+ /** The editor actions the key bindings dispatch into. */
26
+ export interface EditorKeyHandlers {
27
+ /** Ctrl/Cmd+S → the pane's save path. */
28
+ save(): void
29
+ /** Ctrl/Cmd+F → seed our find widget from the selection and open it. */
30
+ openFindForSelection(view: EditorView): void
31
+ /** F3 / Shift+F3 → step through matches. */
32
+ stepFind(view: EditorView, forward: boolean): void
33
+ /** Jump to the previous/next change hunk; false when the panel is closed. */
34
+ stepHunk(delta: 1 | -1): boolean
35
+ /** Escape → close the find widget; false when it was not open. */
36
+ closeFind(): boolean
37
+ }
38
+
39
+ /**
40
+ * Build the editor keymap.
41
+ *
42
+ * Order: the stock keymaps first, then the two additions that make this editor
43
+ * behave like VS Code — `indentWithTab` (Tab / Shift-Tab indent or dedent) and
44
+ * our own shortcuts. `indentWithTab` is deliberately NOT part of CodeMirror's
45
+ * defaults, which is exactly what shipped the "Tab does nothing" bug; a red
46
+ * proof in the gate removes it again.
47
+ */
48
+ export function editorKeymap(handlers: EditorKeyHandlers): KeyBinding[] {
49
+ return [
50
+ ...defaultKeymap,
51
+ ...historyKeymap,
52
+ // Tab inserts a unit of indentation at the caret line; Shift-Tab dedents the
53
+ // selected lines. Read-only views make `indentMore` return false, so the key
54
+ // still falls through to the browser there (diff panes stay navigable).
55
+ indentWithTab,
56
+ { key: 'Mod-s', run: () => { handlers.save(); return true }, preventDefault: true },
57
+ // Ctrl/Cmd+F opens OUR widget (the built-in search panel is never mounted,
58
+ // so `searchKeymap` is deliberately absent). A selection seeds the query,
59
+ // the way it does in VS Code, so find-on-selection is one keystroke.
60
+ {
61
+ key: 'Mod-f',
62
+ run: (view) => {
63
+ handlers.openFindForSelection(view)
64
+ return true
65
+ },
66
+ preventDefault: true,
67
+ },
68
+ { key: 'F3', run: (view) => { handlers.stepFind(view, true); return true }, preventDefault: true },
69
+ { key: 'Shift-F3', run: (view) => { handlers.stepFind(view, false); return true }, preventDefault: true },
70
+ /**
71
+ * Previous / next change hunk.
72
+ *
73
+ * `Mod-Shift-Alt-ArrowUp/Down` is the free combination: defaultKeymap already
74
+ * uses `Mod-Alt-Arrow*` (multi-cursor), `Alt-Arrow*` (move line) and
75
+ * `Shift-Alt-Arrow*` (copy line), and browsers leave this extra Shift alone.
76
+ *
77
+ * NO `preventDefault: true` here, deliberately: CodeMirror prevents the
78
+ * default whenever a binding for that key sets the flag, even if every
79
+ * command returns false (view keymap `runFor`). With the panel closed the
80
+ * handler returns false, and the key must fall through instead of being
81
+ * swallowed — the 2026-11-10 gate found this latent swallow while pinning
82
+ * the Tab fix.
83
+ */
84
+ {
85
+ key: 'Mod-Shift-Alt-ArrowDown',
86
+ run: () => handlers.stepHunk(1),
87
+ },
88
+ {
89
+ key: 'Mod-Shift-Alt-ArrowUp',
90
+ run: () => handlers.stepHunk(-1),
91
+ },
92
+ {
93
+ key: 'Escape',
94
+ run: () => handlers.closeFind(),
95
+ },
96
+ ]
97
+ }