source dump of claude code
at main 38 lines 1.1 kB view raw
1import { 2 type AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, 3 logEvent, 4} from '../../services/analytics/index.js' 5import type { LocalCommandCall } from '../../types/command.js' 6import { getGlobalConfig, saveGlobalConfig } from '../../utils/config.js' 7 8export const call: LocalCommandCall = async () => { 9 const config = getGlobalConfig() 10 let currentMode = config.editorMode || 'normal' 11 12 // Handle backward compatibility - treat 'emacs' as 'normal' 13 if (currentMode === 'emacs') { 14 currentMode = 'normal' 15 } 16 17 const newMode = currentMode === 'normal' ? 'vim' : 'normal' 18 19 saveGlobalConfig(current => ({ 20 ...current, 21 editorMode: newMode, 22 })) 23 24 logEvent('tengu_editor_mode_changed', { 25 mode: newMode as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, 26 source: 27 'command' as AnalyticsMetadata_I_VERIFIED_THIS_IS_NOT_CODE_OR_FILEPATHS, 28 }) 29 30 return { 31 type: 'text', 32 value: `Editor mode set to ${newMode}. ${ 33 newMode === 'vim' 34 ? 'Use Escape key to toggle between INSERT and NORMAL modes.' 35 : 'Using standard (readline) keyboard bindings.' 36 }`, 37 } 38}