Refactor codebase#11
Merged
Merged
Conversation
- Remove unused formatFileSize/formatPermissions imports (findFile.ts) - Replace magic number literals with named constants across extension.ts, menu.ts, openEditors.ts, projectFile.ts, fuzzy.ts, mru.ts - Fix broken column-0 indentation in menu.ts and showBindings.ts - Add console.warn to silent catch blocks in findFile, recentProjects, fuzzy, and extension.ts - Drop unnecessary async/Promise<void> from moveSelection (3 panels) and revealEditorLine (fuzzy.ts) - Change recentProjects.prepareShow return type to void with interface note - Replace Math.random() nonces with crypto.randomUUID() in helpers.ts and menu.ts
…id, memoize trigger bindings - Rename `fuzzyMatch` to `substringMatch` in panel/helpers.ts and all consumers (search/search.ts, buffers/openEditors.ts, whichkey/bindingsPanel.ts); update UI strings from "fuzzy search" to "search" to match the actual substring implementation - Replace hardcoded 'bearylabs.doom' extension id in menu.ts with packageJSON passed via DoomWhichKeyMenu constructor, matching the pattern used elsewhere in the codebase - Memoize getWhichKeyTriggerBindings() at module scope so package.json is parsed once per session rather than on every binding resolution - Rename src/search/fuzzy.ts to src/search/search.ts and DoomFuzzySearchPanel to DoomSearchPanel; update all imports and references in extension.ts and panel/shared.ts
…keys Export isRecord and createNonce from panel/helpers as single sources of truth. Remove the duplicate isRecord from whichkey/bindings and menu, and replace getNonce in menu with createNonce. Expand DOOM_MANAGED_VIM_BINDING_SETTINGS in vimBindings to cover all four managed vim arrays (NonRecursive + plain, both modes), and replace the two hardcoded keysToCheck arrays in extension.ts with that constant.
…script
BLUR_ENABLE_DELAY_MS and SUPPRESS_WINDOW_MS are Node-side module constants,
but the webview client script referenced them as bare identifiers instead of
interpolating their values. Since they don't exist in the webview's JS sandbox,
every render message threw a ReferenceError before render() ran, leaving the
which-key menu blank while keybindings and the bindings QuickPick still worked.
Wrap both usages in ${...} so the numeric values are baked into the generated
client JS, restoring menu rendering.
DOOM_MANAGED_VIM_BINDING_SETTINGS was widened to four keys, conflating two distinct concerns: the arrays Doom installs/merges into (the two NonRecursive arrays, backing isDoomManagedVimBindingSetting used by install and dashboard detection) and the broader set scanned for stale Doom commands during cleanup. Restore DOOM_MANAGED_VIM_BINDING_SETTINGS to the two NonRecursive keys and add DOOM_STALE_VIM_BINDING_SETTINGS covering all four arrays for the stale-scan and detection paths in extension.ts. Extend the centralization test to assert both sets.
Collapse the six bottom-panel pickers (find-file, project files, recent
projects, open editors, search, which-key bindings) onto a common base and
a single HTML template, removing the duplicated controller lifecycle and
embedded CSS/JS scaffolding.
- Add DoomWebviewController (src/panel/controller.ts) owning the view/ready/
viewDisposables/activeIndex/query state, attach/detach, the resolveWebviewView
bootstrap, the render guard, the ready|query|move|activate|close dispatch
skeleton, updateVisibilityContext, and close(). Panels override only getHtml,
filterItems, activateSelection, buildRenderState, itemCount, plus small hooks
(onReady, afterRender, onVisibilityChanged, extraViewDisposables, onMessage,
updateViewMetadata, onDetach/onDispose).
- Add createPanelHtml (src/panel/helpers.ts) producing the shared CSP, chrome
CSS, appendHighlightedText, the focus/setSelectionRange + forceQuery reconcile,
and the keydown handler (Escape/Arrow/Enter/Ctrl+J/Ctrl+K). createFilePickerHtml
delegates to it; each panel passes only its row layout + render-item builder.
Normalize the small CSS drifts (promptbar gap, status alignment, paddings)
to one canonical chrome.
- Standardize selection movement on the in-webview handler: drop the redundant
ctrl+j/k keybindings, the *Move{Down,Up} commands/registrations, and the now
unused moveSelection(). Fixes the double-move on the file pickers and makes
Ctrl+J/K an alias of the arrows on every panel.
No user-visible behavior change beyond unifying Ctrl+J/K navigation. The two
workspace FileSystemWatchers are intentionally left in place.
DoomProjectFilePanel and DoomSearchPanel each lazily created a
createFileSystemWatcher('**/*') stored in a field that was never pushed
to context.subscriptions or disposed, leaking two full-tree watchers for
the session.
Extract a single WorkspaceFileIndex service that owns the one watcher,
exposes getFiles() and an onCacheInvalidated event, and is registered in
context.subscriptions so it is disposed with the extension. Both panels
now subscribe to onCacheInvalidated to clear their own derived caches and
no longer own a watcher.
Decompose src/extension.ts (~1.5k lines mixing onboarding I/O, terminal management, window commands, and ~20 inline command bodies) into cohesive modules, each exposing a register()/named API: - onboarding/keybindingsFile.ts — keybindings.json read/parse/rewrite - onboarding/staleCleanup.ts — stale-settings cleanup + legacy binding migration - onboarding/onboardingCommands.ts — doom.install, doom.cleanup, doom.dashboard - terminal/terminalCommands.ts — editor/AI-CLI and panel terminal commands - window/windowCommands.ts — doom.windowDelete and window focus/split commands activate() is now a short wiring list that calls each module's register(). Also: - Collapse the three copy-paste AI-CLI commands into a single table-driven openCliTerminal() helper that derives EDITOR_TERMINAL_NAMES. - Move the pure resolveWindowDeleteAction into window/windowCommands.ts, removing the command modules' import dependency on extension.ts; update the test import to match.
Declare all user-invokable commands in contributes.commands; keep internal routing and mid-keystroke mode-state commands (whichKeyHide, sidebarHide, panelHide, terminalEscape*) out of the palette. Replace the hand-picked command lists in extension.test.ts with a dynamic cross-check that reads contributes.commands and contributes.keybindings from package.json and asserts every referenced command is registered — drift now fails CI automatically. Document the declaration rule in CONTRIBUTING.md.
Replace the in-process WorkspaceFileIndex line cache with debounced, cancellable calls to doom-workspace.searchText. Drops workspaceCache, loadSequence, the file-size limit, and background preloading; results now stream from ripgrep/git grep on the workspace host.
close(): skip closePanel and focus-restore when the panel was never revealed (view not visible), so deferred editor focus no longer races the panel.focus of the command that runs next. setActiveController(): always detach the previous controller, even when the same one is reused, so its ready flag resets before showMode's re-attach replaces the webview HTML — blocking render() until the new webview signals ready.
The doom-workspace.readDirectory command now returns raw size/mode numbers instead of pre-formatted strings. Format them here through formatFileSize and formatPermissions from panel/helpers.ts, matching how the project file picker already handles listProjectFiles. Display output is unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.