A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
Prefer type guard over type assertion for Vim macro state (#8708)
Trevor Manz305e8a291c12
diff --git a/frontend/src/core/codemirror/keymaps/vim.ts b/frontend/src/core/codemirror/keymaps/vim.tsindex c373e58e6e..b6563abca1 100644--- a/frontend/src/core/codemirror/keymaps/vim.ts+++ b/frontend/src/core/codemirror/keymaps/vim.ts@@ -247,21 +247,26 @@ function applyVimCommands(vimCommands: VimCommand[]) {}}-type VimWithGlobalState = typeof Vim & {- getVimGlobalState_?: () => {+interface ExtendedVim {+ getVimGlobalState_: () => {macroModeState?: {isRecording: boolean;isPlaying: boolean;};};-};+}++function isExtendedVim(vim: typeof Vim): vim is typeof Vim & ExtendedVim {+ return (+ "getVimGlobalState_" in vim && typeof vim.getVimGlobalState_ === "function"+ );+}function isMacroActive() {- const getGlobalState = (Vim as VimWithGlobalState).getVimGlobalState_;- if (typeof getGlobalState !== "function") {+ if (!isExtendedVim(Vim)) {return false;}- const macroModeState = getGlobalState()?.macroModeState;+ const macroModeState = Vim.getVimGlobalState_()?.macroModeState;if (!macroModeState) {return false;}