Skip to content

Commit 0cc7091

Browse files
committed
Remove vim mode from mini-editor, which didn't really work anyway
1 parent a080ee3 commit 0cc7091

File tree

10 files changed

+11
-61
lines changed

10 files changed

+11
-61
lines changed

build_client.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ async function buildCopyBundleAssets() {
6262
sourcemap: "linked",
6363
minify: true,
6464
jsxFactory: "h",
65-
metafile: true,
65+
// metafile: true,
6666
splitting: true,
6767
format: "esm",
6868
chunkNames: ".client/[name]-[hash]",
@@ -85,9 +85,12 @@ async function buildCopyBundleAssets() {
8585
"/", // The index page
8686
"/.client/manifest.json", // Dynamically generated by the server, but needed for PWA
8787
...allFiles
88-
.filter((f) =>
89-
!f.endsWith(".map") && f !== "auth.html" && f !== "index.html" &&
90-
f !== "LICENSE.md"
88+
.filter(
89+
(f) =>
90+
!f.endsWith(".map") &&
91+
f !== "auth.html" &&
92+
f !== "index.html" &&
93+
f !== "LICENSE.md",
9194
)
9295
.map((f) => `/.client/${f}`),
9396
];

client/components/anything_picker.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,13 @@ export function AnythingPicker({
2121
extensions,
2222
onNavigate,
2323
onModeSwitch,
24-
vimMode,
2524
mode,
2625
darkMode,
2726
currentPath,
2827
}: {
2928
allDocuments: DocumentMeta[];
3029
allPages: PageMeta[];
3130
extensions: Set<string>;
32-
vimMode: boolean;
3331
darkMode?: boolean;
3432
mode: "page" | "meta" | "document" | "all";
3533
onNavigate: (name: string | null) => void;
@@ -178,7 +176,6 @@ export function AnythingPicker({
178176
}
179177
label="Open"
180178
options={options}
181-
vimMode={vimMode}
182179
darkMode={darkMode}
183180
phrasePreprocessor={(phrase) => {
184181
phrase = phrase.replaceAll(tagRegex, "").trim();

client/components/basic_modals.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@ import type { ComponentChildren, Ref } from "preact";
55
export function Prompt({
66
message,
77
defaultValue,
8-
vimMode,
98
darkMode,
109
callback,
1110
}: {
1211
message: string;
1312
defaultValue?: string;
14-
vimMode: boolean;
1513
darkMode: boolean | undefined;
1614
callback: (value?: string) => void;
1715
}) {
@@ -26,8 +24,6 @@ export function Prompt({
2624
<label>{message}</label>
2725
<MiniEditor
2826
text={defaultValue || ""}
29-
vimMode={vimMode}
30-
vimStartInInsertMode={true}
3127
focus={true}
3228
darkMode={darkMode}
3329
onEnter={(text) => {

client/components/command_palette.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ import { isMacLike } from "../codemirror/editor_state.ts";
77
export function CommandPalette({
88
commands,
99
onTrigger,
10-
vimMode,
1110
darkMode,
1211
}: {
1312
commands: Map<string, Command>;
14-
vimMode: boolean;
1513
darkMode?: boolean;
1614
onTrigger: (command: Command | undefined) => void;
1715
}) {
@@ -36,7 +34,6 @@ export function CommandPalette({
3634
options={options}
3735
allowNew={false}
3836
icon={Terminal}
39-
vimMode={vimMode}
4037
darkMode={darkMode}
4138
helpText="Start typing the command name to filter results, press <code>Enter</code> to run."
4239
onSelect={(opt) => {

client/components/filter.tsx

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ export function FilterList({
1717
label,
1818
onSelect,
1919
onKeyPress,
20-
vimMode,
2120
darkMode,
2221
preFilter,
2322
phrasePreprocessor,
@@ -34,7 +33,6 @@ export function FilterList({
3433
onSelect: (option: FilterOption | undefined) => void;
3534
preFilter?: (options: FilterOption[], phrase: string) => FilterOption[];
3635
phrasePreprocessor?: (phrase: string) => string;
37-
vimMode: boolean;
3836
darkMode?: boolean;
3937
allowNew?: boolean;
4038
completePrefix?: string;
@@ -107,8 +105,6 @@ export function FilterList({
107105
<label>{label}</label>
108106
<MiniEditor
109107
text={text}
110-
vimMode={vimMode}
111-
vimStartInInsertMode={true}
112108
focus={true}
113109
darkMode={darkMode}
114110
placeholderText={placeholder}

client/components/mini_editor.tsx

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import {
88
ViewPlugin,
99
type ViewUpdate,
1010
} from "@codemirror/view";
11-
import { getVimModule } from "../vim_loader.ts";
1211
import { createCommandKeyBindings } from "../codemirror/editor_state.ts";
1312

1413
type MiniEditorEvents = {
@@ -23,9 +22,7 @@ type MiniEditorEvents = {
2322
export function MiniEditor({
2423
text,
2524
placeholderText,
26-
vimMode,
2725
darkMode,
28-
vimStartInInsertMode,
2926
onBlur,
3027
onEscape,
3128
onKeyUp,
@@ -37,15 +34,12 @@ export function MiniEditor({
3734
}: {
3835
text: string;
3936
placeholderText?: string;
40-
vimMode: boolean;
4137
darkMode?: boolean;
42-
vimStartInInsertMode?: boolean;
4338
focus?: boolean;
4439
editable: boolean;
4540
} & MiniEditorEvents) {
4641
const editorDiv = useRef<HTMLDivElement>(null);
4742
const editorViewRef = useRef<EditorView>();
48-
const vimModeRef = useRef<string>("normal");
4943
// TODO: This super duper ugly, but I don't know how to avoid it
5044
// Due to how MiniCodeEditor is built, it captures the closures of all callback functions
5145
// which results in them pointing to old state variables, to avoid this we do this...
@@ -102,7 +96,7 @@ export function MiniEditor({
10296
});
10397
}
10498
}
105-
}, [text, vimMode]);
99+
}, [text]);
106100

107101
let onBlurred = false,
108102
onEntered = false;
@@ -128,31 +122,11 @@ export function MiniEditor({
128122
);
129123

130124
function buildEditorState() {
131-
// When vim mode is active, we need for CM to have created the new state
132-
// and the subscribe to the vim mode's events
133-
// This needs to happen in the next tick, so we wait a tick with setTimeout
134-
const vimMod = getVimModule();
135-
if (vimMode && vimMod) {
136-
// Only applies to vim mode
137-
setTimeout(() => {
138-
const cm = vimMod.getCM(editorViewRef.current!)!;
139-
cm.on("vim-mode-change", ({ mode }: { mode: string }) => {
140-
vimModeRef.current = mode;
141-
});
142-
if (vimStartInInsertMode) {
143-
vimMod.Vim.handleKey(cm, "i", "+input");
144-
}
145-
});
146-
}
147125
return EditorState.create({
148126
doc: text,
149127
extensions: [
150128
EditorView.theme({}, { dark: darkMode }),
151-
// Insert command bindings before vim-mode to ensure they're available
152-
// in normal mode. See editor_state.ts for more details.
153129
createCommandKeyBindings(globalThis.client),
154-
// Enable vim mode, or not (uses already-loaded module if available)
155-
[...(vimMode && vimMod ? [vimMod.vim()] : [])],
156130
[
157131
...(editable
158132
? []
@@ -195,12 +169,7 @@ export function MiniEditor({
195169
return false;
196170
}
197171
if (event.key === "Enter") {
198-
// Enter should be handled by the keymap, except when in Vim normal mode
199-
// because then it's disabled
200-
if (vimMode && vimModeRef.current === "normal") {
201-
onEnterHandler(view, event.shiftKey);
202-
return true;
203-
}
172+
// Enter should be handled by the keymap
204173
return false;
205174
}
206175
if (callbacksRef.current!.onKeyUp) {

client/components/top_bar.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ export function TopBar({
153153
onDismissNotification,
154154
actionButtons,
155155
darkMode,
156-
vimMode,
157156
progressPercentage,
158157
progressType,
159158
lhs,
@@ -170,7 +169,6 @@ export function TopBar({
170169
isLoading: boolean;
171170
notifications: Notification[];
172171
darkMode?: boolean;
173-
vimMode: boolean;
174172
progressPercentage?: number;
175173
progressType?: string;
176174
onRename: (newName?: string) => Promise<void>;
@@ -201,7 +199,6 @@ export function TopBar({
201199
>
202200
<MiniEditor
203201
text={pageName ?? ""}
204-
vimMode={vimMode}
205202
darkMode={darkMode}
206203
onBlur={(newName) => {
207204
if (newName !== pageName) {

client/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { type OutputUnit, Validator, format } from "@cfworker/json-schema";
22

33
// Register custom formats (shared with jsonschema.ts)
4-
format["email"] = (data: string) => data.includes("@");
4+
format.email = (data: string) => data.includes("@");
55
format["page-ref"] = (data: string) =>
66
data.startsWith("[[") && data.endsWith("]]");
77

client/editor_ui.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,6 @@ export class MainUI {
269269
}
270270
currentPath={client.currentPath()}
271271
mode={viewState.pageNavigatorMode}
272-
vimMode={viewState.uiOptions.vimMode}
273272
darkMode={viewState.uiOptions.darkMode}
274273
onModeSwitch={(mode) => {
275274
dispatch({ type: "stop-navigate" });
@@ -363,7 +362,6 @@ export class MainUI {
363362
});
364363
}}
365364
commands={client.getCommandsByContext(viewState)}
366-
vimMode={viewState.uiOptions.vimMode}
367365
darkMode={viewState.uiOptions.darkMode}
368366
/>
369367
)}
@@ -372,7 +370,6 @@ export class MainUI {
372370
label={viewState.filterBoxLabel}
373371
placeholder={viewState.filterBoxPlaceHolder}
374372
options={viewState.filterBoxOptions}
375-
vimMode={viewState.uiOptions.vimMode}
376373
darkMode={viewState.uiOptions.darkMode}
377374
allowNew={false}
378375
helpText={viewState.filterBoxHelpText}
@@ -383,7 +380,6 @@ export class MainUI {
383380
<Prompt
384381
message={viewState.promptMessage!}
385382
defaultValue={viewState.promptDefaultValue}
386-
vimMode={viewState.uiOptions.vimMode}
387383
darkMode={viewState.uiOptions.darkMode}
388384
callback={(value) => {
389385
dispatch({ type: "hide-prompt" });
@@ -411,7 +407,6 @@ export class MainUI {
411407
isOnline={viewState.isOnline}
412408
unsavedChanges={viewState.unsavedChanges}
413409
isLoading={viewState.isLoading}
414-
vimMode={viewState.uiOptions.vimMode}
415410
darkMode={viewState.uiOptions.darkMode}
416411
progressPercentage={viewState.progressPercentage}
417412
progressType={viewState.progressType}

client/plugos/syscalls/jsonschema.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import type { SysCallMapping } from "../system.ts";
22
import { type OutputUnit, Validator, format } from "@cfworker/json-schema";
33

44
// Register custom formats
5-
format["email"] = (data: string) => data.includes("@");
5+
format.email = (data: string) => data.includes("@");
66
format["page-ref"] = (data: string) =>
77
data.startsWith("[[") && data.endsWith("]]");
88

0 commit comments

Comments
 (0)