fss-link 1.0.49 → 1.0.51

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.
Files changed (419) hide show
  1. package/dist/index.js +0 -0
  2. package/dist/package.json +2 -2
  3. package/dist/src/config/auth.js +8 -5
  4. package/dist/src/config/auth.js.map +1 -1
  5. package/dist/src/config/database.d.ts +103 -11
  6. package/dist/src/config/database.js +301 -59
  7. package/dist/src/config/database.js.map +1 -1
  8. package/dist/src/config/databaseBackup.d.ts +114 -0
  9. package/dist/src/config/databaseBackup.js +334 -0
  10. package/dist/src/config/databaseBackup.js.map +1 -0
  11. package/dist/src/config/databaseMigrations.d.ts +63 -0
  12. package/dist/src/config/databaseMigrations.js +379 -0
  13. package/dist/src/config/databaseMigrations.js.map +1 -0
  14. package/dist/src/config/databasePool.d.ts +70 -0
  15. package/dist/src/config/databasePool.js +193 -0
  16. package/dist/src/config/databasePool.js.map +1 -0
  17. package/dist/src/config/queryOptimizer.d.ts +127 -0
  18. package/dist/src/config/queryOptimizer.js +309 -0
  19. package/dist/src/config/queryOptimizer.js.map +1 -0
  20. package/dist/src/utils/sandbox.js +2 -8
  21. package/dist/src/utils/sandbox.js.map +1 -1
  22. package/dist/src/validateNonInterActiveAuth.js +3 -7
  23. package/dist/src/validateNonInterActiveAuth.js.map +1 -1
  24. package/dist/tsconfig.tsbuildinfo +1 -1
  25. package/package.json +2 -2
  26. package/dist/commands/mcp/add.test.ts +0 -122
  27. package/dist/commands/mcp/add.ts +0 -222
  28. package/dist/commands/mcp/list.test.ts +0 -154
  29. package/dist/commands/mcp/list.ts +0 -139
  30. package/dist/commands/mcp/remove.test.ts +0 -69
  31. package/dist/commands/mcp/remove.ts +0 -60
  32. package/dist/commands/mcp.test.ts +0 -55
  33. package/dist/commands/mcp.ts +0 -27
  34. package/dist/config/apiValidation.test.ts +0 -118
  35. package/dist/config/auth.test.ts +0 -79
  36. package/dist/config/auth.ts +0 -100
  37. package/dist/config/config.integration.test.ts +0 -407
  38. package/dist/config/config.test.ts +0 -1952
  39. package/dist/config/config.ts +0 -690
  40. package/dist/config/database.test.ts +0 -96
  41. package/dist/config/database.ts +0 -824
  42. package/dist/config/extension.test.ts +0 -236
  43. package/dist/config/extension.ts +0 -180
  44. package/dist/config/keyBindings.test.ts +0 -62
  45. package/dist/config/keyBindings.ts +0 -184
  46. package/dist/config/modelManager.ts +0 -326
  47. package/dist/config/providerManager.ts +0 -244
  48. package/dist/config/providerPersistence.test.ts +0 -377
  49. package/dist/config/providerPersistence.ts +0 -105
  50. package/dist/config/sandboxConfig.ts +0 -107
  51. package/dist/config/settings.test.ts +0 -1424
  52. package/dist/config/settings.ts +0 -517
  53. package/dist/config/settingsSchema.test.ts +0 -252
  54. package/dist/config/settingsSchema.ts +0 -728
  55. package/dist/config/trustedFolders.test.ts +0 -208
  56. package/dist/config/trustedFolders.ts +0 -167
  57. package/dist/gemini.test.tsx +0 -252
  58. package/dist/gemini.tsx +0 -357
  59. package/dist/generated/git-commit.ts +0 -10
  60. package/dist/index.ts +0 -21
  61. package/dist/nonInteractiveCli.test.ts +0 -276
  62. package/dist/nonInteractiveCli.ts +0 -143
  63. package/dist/patches/is-in-ci.ts +0 -17
  64. package/dist/services/BuiltinCommandLoader.test.ts +0 -127
  65. package/dist/services/BuiltinCommandLoader.ts +0 -95
  66. package/dist/services/CommandService.test.ts +0 -352
  67. package/dist/services/CommandService.ts +0 -103
  68. package/dist/services/FileCommandLoader.test.ts +0 -1002
  69. package/dist/services/FileCommandLoader.ts +0 -289
  70. package/dist/services/McpPromptLoader.ts +0 -231
  71. package/dist/services/SearchEngineConfigProvider.ts +0 -100
  72. package/dist/services/prompt-processors/argumentProcessor.test.ts +0 -41
  73. package/dist/services/prompt-processors/argumentProcessor.ts +0 -23
  74. package/dist/services/prompt-processors/shellProcessor.test.ts +0 -709
  75. package/dist/services/prompt-processors/shellProcessor.ts +0 -248
  76. package/dist/services/prompt-processors/types.ts +0 -44
  77. package/dist/services/types.ts +0 -24
  78. package/dist/src/config/apiValidation.test.d.ts +0 -6
  79. package/dist/src/config/apiValidation.test.js +0 -99
  80. package/dist/src/config/apiValidation.test.js.map +0 -1
  81. package/dist/src/config/database.test.d.ts +0 -6
  82. package/dist/src/config/database.test.js +0 -80
  83. package/dist/src/config/database.test.js.map +0 -1
  84. package/dist/src/config/providerManager.d.ts +0 -74
  85. package/dist/src/config/providerManager.js +0 -203
  86. package/dist/src/config/providerManager.js.map +0 -1
  87. package/dist/src/config/providerPersistence.test.d.ts +0 -6
  88. package/dist/src/config/providerPersistence.test.js +0 -283
  89. package/dist/src/config/providerPersistence.test.js.map +0 -1
  90. package/dist/src/ui/components/GeminiKeyDialog.d.ts +0 -11
  91. package/dist/src/ui/components/GeminiKeyDialog.js +0 -156
  92. package/dist/src/ui/components/GeminiKeyDialog.js.map +0 -1
  93. package/dist/src/ui/components/OpenAIEndpointDialog.d.ts +0 -19
  94. package/dist/src/ui/components/OpenAIEndpointDialog.js +0 -163
  95. package/dist/src/ui/components/OpenAIEndpointDialog.js.map +0 -1
  96. package/dist/test-setup.ts +0 -12
  97. package/dist/test-utils/customMatchers.ts +0 -65
  98. package/dist/test-utils/mockCommandContext.test.ts +0 -62
  99. package/dist/test-utils/mockCommandContext.ts +0 -105
  100. package/dist/test-utils/render.tsx +0 -18
  101. package/dist/ui/App.test.tsx +0 -2181
  102. package/dist/ui/App.tsx +0 -1344
  103. package/dist/ui/IdeIntegrationNudge.tsx +0 -98
  104. package/dist/ui/__snapshots__/App.test.tsx.snap +0 -124
  105. package/dist/ui/colors.ts +0 -56
  106. package/dist/ui/commands/aboutCommand.test.ts +0 -153
  107. package/dist/ui/commands/aboutCommand.ts +0 -49
  108. package/dist/ui/commands/authCommand.test.ts +0 -36
  109. package/dist/ui/commands/authCommand.ts +0 -17
  110. package/dist/ui/commands/bugCommand.test.ts +0 -114
  111. package/dist/ui/commands/bugCommand.ts +0 -92
  112. package/dist/ui/commands/chatCommand.test.ts +0 -414
  113. package/dist/ui/commands/chatCommand.ts +0 -280
  114. package/dist/ui/commands/clearCommand.test.ts +0 -100
  115. package/dist/ui/commands/clearCommand.ts +0 -29
  116. package/dist/ui/commands/compressCommand.test.ts +0 -129
  117. package/dist/ui/commands/compressCommand.ts +0 -78
  118. package/dist/ui/commands/contextCommand.ts +0 -132
  119. package/dist/ui/commands/copyCommand.test.ts +0 -296
  120. package/dist/ui/commands/copyCommand.ts +0 -67
  121. package/dist/ui/commands/corgiCommand.test.ts +0 -34
  122. package/dist/ui/commands/corgiCommand.ts +0 -16
  123. package/dist/ui/commands/directoryCommand.test.tsx +0 -185
  124. package/dist/ui/commands/directoryCommand.tsx +0 -179
  125. package/dist/ui/commands/docsCommand.test.ts +0 -99
  126. package/dist/ui/commands/docsCommand.ts +0 -42
  127. package/dist/ui/commands/editorCommand.test.ts +0 -30
  128. package/dist/ui/commands/editorCommand.ts +0 -21
  129. package/dist/ui/commands/extensionsCommand.test.ts +0 -67
  130. package/dist/ui/commands/extensionsCommand.ts +0 -46
  131. package/dist/ui/commands/helpCommand.test.ts +0 -52
  132. package/dist/ui/commands/helpCommand.ts +0 -23
  133. package/dist/ui/commands/ideCommand.test.ts +0 -255
  134. package/dist/ui/commands/ideCommand.ts +0 -283
  135. package/dist/ui/commands/initCommand.test.ts +0 -127
  136. package/dist/ui/commands/initCommand.ts +0 -117
  137. package/dist/ui/commands/mcpCommand.test.ts +0 -1057
  138. package/dist/ui/commands/mcpCommand.ts +0 -531
  139. package/dist/ui/commands/memoryCommand.test.ts +0 -344
  140. package/dist/ui/commands/memoryCommand.ts +0 -305
  141. package/dist/ui/commands/privacyCommand.test.ts +0 -38
  142. package/dist/ui/commands/privacyCommand.ts +0 -17
  143. package/dist/ui/commands/quitCommand.test.ts +0 -55
  144. package/dist/ui/commands/quitCommand.ts +0 -36
  145. package/dist/ui/commands/restoreCommand.test.ts +0 -250
  146. package/dist/ui/commands/restoreCommand.ts +0 -157
  147. package/dist/ui/commands/searchEngineSetupCommand.ts +0 -18
  148. package/dist/ui/commands/settingsCommand.test.ts +0 -36
  149. package/dist/ui/commands/settingsCommand.ts +0 -17
  150. package/dist/ui/commands/setupGithubCommand.test.ts +0 -238
  151. package/dist/ui/commands/setupGithubCommand.ts +0 -212
  152. package/dist/ui/commands/speakCommand.ts +0 -175
  153. package/dist/ui/commands/statsCommand.test.ts +0 -78
  154. package/dist/ui/commands/statsCommand.ts +0 -70
  155. package/dist/ui/commands/terminalSetupCommand.test.ts +0 -85
  156. package/dist/ui/commands/terminalSetupCommand.ts +0 -45
  157. package/dist/ui/commands/themeCommand.test.ts +0 -38
  158. package/dist/ui/commands/themeCommand.ts +0 -17
  159. package/dist/ui/commands/toolsCommand.test.ts +0 -105
  160. package/dist/ui/commands/toolsCommand.ts +0 -71
  161. package/dist/ui/commands/ttsCommand.ts +0 -143
  162. package/dist/ui/commands/types.ts +0 -204
  163. package/dist/ui/commands/vimCommand.ts +0 -25
  164. package/dist/ui/commands/voiceCommand.ts +0 -125
  165. package/dist/ui/components/AboutBox.tsx +0 -133
  166. package/dist/ui/components/AsciiArt.ts +0 -54
  167. package/dist/ui/components/AuthDialog.test.tsx +0 -334
  168. package/dist/ui/components/AuthDialog.tsx +0 -289
  169. package/dist/ui/components/AuthInProgress.tsx +0 -62
  170. package/dist/ui/components/AutoAcceptIndicator.tsx +0 -47
  171. package/dist/ui/components/ConsoleSummaryDisplay.tsx +0 -35
  172. package/dist/ui/components/ContextSummaryDisplay.test.tsx +0 -85
  173. package/dist/ui/components/ContextSummaryDisplay.tsx +0 -120
  174. package/dist/ui/components/ContextUsageDisplay.tsx +0 -77
  175. package/dist/ui/components/DebugProfiler.tsx +0 -36
  176. package/dist/ui/components/DetailedMessagesDisplay.tsx +0 -82
  177. package/dist/ui/components/EditorSettingsDialog.tsx +0 -172
  178. package/dist/ui/components/FolderTrustDialog.test.tsx +0 -36
  179. package/dist/ui/components/FolderTrustDialog.tsx +0 -74
  180. package/dist/ui/components/Footer.test.tsx +0 -159
  181. package/dist/ui/components/Footer.tsx +0 -158
  182. package/dist/ui/components/GeminiKeyDialog.tsx +0 -252
  183. package/dist/ui/components/GeminiRespondingSpinner.tsx +0 -34
  184. package/dist/ui/components/Header.test.tsx +0 -44
  185. package/dist/ui/components/Header.tsx +0 -70
  186. package/dist/ui/components/Help.tsx +0 -174
  187. package/dist/ui/components/HistoryItemDisplay.test.tsx +0 -125
  188. package/dist/ui/components/HistoryItemDisplay.tsx +0 -98
  189. package/dist/ui/components/InputPrompt.test.tsx +0 -1467
  190. package/dist/ui/components/InputPrompt.tsx +0 -641
  191. package/dist/ui/components/LMStudioModelPrompt.tsx +0 -215
  192. package/dist/ui/components/LoadingIndicator.test.tsx +0 -296
  193. package/dist/ui/components/LoadingIndicator.tsx +0 -82
  194. package/dist/ui/components/MemoryUsageDisplay.tsx +0 -36
  195. package/dist/ui/components/ModelStatsDisplay.test.tsx +0 -252
  196. package/dist/ui/components/ModelStatsDisplay.tsx +0 -197
  197. package/dist/ui/components/OllamaModelPrompt.tsx +0 -206
  198. package/dist/ui/components/OpenAIEndpointDialog.tsx +0 -261
  199. package/dist/ui/components/OpenAIKeyPrompt.test.tsx +0 -64
  200. package/dist/ui/components/OpenAIKeyPrompt.tsx +0 -197
  201. package/dist/ui/components/PrepareLabel.tsx +0 -48
  202. package/dist/ui/components/SearchEngineConfigDialog.tsx +0 -280
  203. package/dist/ui/components/SessionSummaryDisplay.test.tsx +0 -75
  204. package/dist/ui/components/SessionSummaryDisplay.tsx +0 -18
  205. package/dist/ui/components/SettingsDialog.test.tsx +0 -865
  206. package/dist/ui/components/SettingsDialog.tsx +0 -753
  207. package/dist/ui/components/ShellConfirmationDialog.test.tsx +0 -53
  208. package/dist/ui/components/ShellConfirmationDialog.tsx +0 -103
  209. package/dist/ui/components/ShellModeIndicator.tsx +0 -18
  210. package/dist/ui/components/ShowMoreLines.tsx +0 -40
  211. package/dist/ui/components/StatsDisplay.test.tsx +0 -401
  212. package/dist/ui/components/StatsDisplay.tsx +0 -273
  213. package/dist/ui/components/SuggestionsDisplay.tsx +0 -102
  214. package/dist/ui/components/ThemeDialog.tsx +0 -310
  215. package/dist/ui/components/Tips.tsx +0 -45
  216. package/dist/ui/components/TodoDisplay.test.tsx +0 -97
  217. package/dist/ui/components/TodoDisplay.tsx +0 -72
  218. package/dist/ui/components/ToolStatsDisplay.test.tsx +0 -180
  219. package/dist/ui/components/ToolStatsDisplay.tsx +0 -208
  220. package/dist/ui/components/UpdateNotification.tsx +0 -23
  221. package/dist/ui/components/WelcomeBackDialog.tsx +0 -290
  222. package/dist/ui/components/__snapshots__/IDEContextDetailDisplay.test.tsx.snap +0 -24
  223. package/dist/ui/components/__snapshots__/ModelStatsDisplay.test.tsx.snap +0 -121
  224. package/dist/ui/components/__snapshots__/SessionSummaryDisplay.test.tsx.snap +0 -30
  225. package/dist/ui/components/__snapshots__/ShellConfirmationDialog.test.tsx.snap +0 -21
  226. package/dist/ui/components/__snapshots__/StatsDisplay.test.tsx.snap +0 -264
  227. package/dist/ui/components/__snapshots__/ToolStatsDisplay.test.tsx.snap +0 -91
  228. package/dist/ui/components/messages/CompressionMessage.tsx +0 -49
  229. package/dist/ui/components/messages/DiffRenderer.test.tsx +0 -365
  230. package/dist/ui/components/messages/DiffRenderer.tsx +0 -358
  231. package/dist/ui/components/messages/ErrorMessage.tsx +0 -31
  232. package/dist/ui/components/messages/GeminiMessage.tsx +0 -43
  233. package/dist/ui/components/messages/GeminiMessageContent.tsx +0 -43
  234. package/dist/ui/components/messages/InfoMessage.tsx +0 -32
  235. package/dist/ui/components/messages/ToolConfirmationMessage.test.tsx +0 -58
  236. package/dist/ui/components/messages/ToolConfirmationMessage.tsx +0 -297
  237. package/dist/ui/components/messages/ToolGroupMessage.tsx +0 -126
  238. package/dist/ui/components/messages/ToolMessage.test.tsx +0 -183
  239. package/dist/ui/components/messages/ToolMessage.tsx +0 -296
  240. package/dist/ui/components/messages/UserMessage.tsx +0 -43
  241. package/dist/ui/components/messages/UserShellMessage.tsx +0 -25
  242. package/dist/ui/components/shared/MaxSizedBox.test.tsx +0 -425
  243. package/dist/ui/components/shared/MaxSizedBox.tsx +0 -624
  244. package/dist/ui/components/shared/RadioButtonSelect.test.tsx +0 -181
  245. package/dist/ui/components/shared/RadioButtonSelect.tsx +0 -234
  246. package/dist/ui/components/shared/__snapshots__/RadioButtonSelect.test.tsx.snap +0 -47
  247. package/dist/ui/components/shared/text-buffer.test.ts +0 -1728
  248. package/dist/ui/components/shared/text-buffer.ts +0 -2227
  249. package/dist/ui/components/shared/vim-buffer-actions.test.ts +0 -1119
  250. package/dist/ui/components/shared/vim-buffer-actions.ts +0 -814
  251. package/dist/ui/constants.ts +0 -17
  252. package/dist/ui/contexts/KeypressContext.test.tsx +0 -391
  253. package/dist/ui/contexts/KeypressContext.tsx +0 -440
  254. package/dist/ui/contexts/OverflowContext.tsx +0 -87
  255. package/dist/ui/contexts/SessionContext.test.tsx +0 -132
  256. package/dist/ui/contexts/SessionContext.tsx +0 -143
  257. package/dist/ui/contexts/SettingsContext.tsx +0 -20
  258. package/dist/ui/contexts/StreamingContext.tsx +0 -22
  259. package/dist/ui/contexts/VimModeContext.tsx +0 -79
  260. package/dist/ui/editors/editorSettingsManager.ts +0 -66
  261. package/dist/ui/hooks/atCommandProcessor.test.ts +0 -1102
  262. package/dist/ui/hooks/atCommandProcessor.ts +0 -485
  263. package/dist/ui/hooks/shellCommandProcessor.test.ts +0 -481
  264. package/dist/ui/hooks/shellCommandProcessor.ts +0 -314
  265. package/dist/ui/hooks/slashCommandProcessor.test.ts +0 -1044
  266. package/dist/ui/hooks/slashCommandProcessor.ts +0 -595
  267. package/dist/ui/hooks/useAtCompletion.test.ts +0 -497
  268. package/dist/ui/hooks/useAtCompletion.ts +0 -244
  269. package/dist/ui/hooks/useAuthCommand.ts +0 -129
  270. package/dist/ui/hooks/useAutoAcceptIndicator.test.ts +0 -300
  271. package/dist/ui/hooks/useAutoAcceptIndicator.ts +0 -52
  272. package/dist/ui/hooks/useBracketedPaste.ts +0 -37
  273. package/dist/ui/hooks/useCommandCompletion.test.ts +0 -518
  274. package/dist/ui/hooks/useCommandCompletion.tsx +0 -238
  275. package/dist/ui/hooks/useCompletion.ts +0 -128
  276. package/dist/ui/hooks/useConsoleMessages.test.ts +0 -147
  277. package/dist/ui/hooks/useConsoleMessages.ts +0 -110
  278. package/dist/ui/hooks/useEditorSettings.test.ts +0 -283
  279. package/dist/ui/hooks/useEditorSettings.ts +0 -75
  280. package/dist/ui/hooks/useFocus.test.ts +0 -119
  281. package/dist/ui/hooks/useFocus.ts +0 -48
  282. package/dist/ui/hooks/useFolderTrust.test.ts +0 -159
  283. package/dist/ui/hooks/useFolderTrust.ts +0 -72
  284. package/dist/ui/hooks/useGeminiStream.test.tsx +0 -1998
  285. package/dist/ui/hooks/useGeminiStream.ts +0 -1017
  286. package/dist/ui/hooks/useGitBranchName.test.ts +0 -280
  287. package/dist/ui/hooks/useGitBranchName.ts +0 -79
  288. package/dist/ui/hooks/useHistoryManager.test.ts +0 -202
  289. package/dist/ui/hooks/useHistoryManager.ts +0 -111
  290. package/dist/ui/hooks/useInputHistory.test.ts +0 -261
  291. package/dist/ui/hooks/useInputHistory.ts +0 -111
  292. package/dist/ui/hooks/useKeypress.test.ts +0 -280
  293. package/dist/ui/hooks/useKeypress.ts +0 -39
  294. package/dist/ui/hooks/useKittyKeyboardProtocol.ts +0 -31
  295. package/dist/ui/hooks/useLoadingIndicator.test.ts +0 -139
  296. package/dist/ui/hooks/useLoadingIndicator.ts +0 -57
  297. package/dist/ui/hooks/useLogger.ts +0 -32
  298. package/dist/ui/hooks/useMessageQueue.test.ts +0 -226
  299. package/dist/ui/hooks/useMessageQueue.ts +0 -69
  300. package/dist/ui/hooks/usePhraseCycler.test.ts +0 -145
  301. package/dist/ui/hooks/usePhraseCycler.ts +0 -198
  302. package/dist/ui/hooks/usePrivacySettings.test.ts +0 -242
  303. package/dist/ui/hooks/usePrivacySettings.ts +0 -150
  304. package/dist/ui/hooks/useReactToolScheduler.ts +0 -309
  305. package/dist/ui/hooks/useRefreshMemoryCommand.ts +0 -7
  306. package/dist/ui/hooks/useReverseSearchCompletion.test.tsx +0 -260
  307. package/dist/ui/hooks/useReverseSearchCompletion.tsx +0 -95
  308. package/dist/ui/hooks/useSettingsCommand.ts +0 -25
  309. package/dist/ui/hooks/useShellHistory.test.ts +0 -219
  310. package/dist/ui/hooks/useShellHistory.ts +0 -133
  311. package/dist/ui/hooks/useShowMemoryCommand.ts +0 -75
  312. package/dist/ui/hooks/useSlashCompletion.test.ts +0 -434
  313. package/dist/ui/hooks/useSlashCompletion.ts +0 -187
  314. package/dist/ui/hooks/useStateAndRef.ts +0 -36
  315. package/dist/ui/hooks/useTerminalSize.ts +0 -32
  316. package/dist/ui/hooks/useThemeCommand.ts +0 -110
  317. package/dist/ui/hooks/useTimer.test.ts +0 -120
  318. package/dist/ui/hooks/useTimer.ts +0 -65
  319. package/dist/ui/hooks/useToolScheduler.test.ts +0 -1123
  320. package/dist/ui/hooks/useWelcomeBack.ts +0 -253
  321. package/dist/ui/hooks/vim.test.ts +0 -1691
  322. package/dist/ui/hooks/vim.ts +0 -784
  323. package/dist/ui/keyMatchers.test.ts +0 -337
  324. package/dist/ui/keyMatchers.ts +0 -105
  325. package/dist/ui/privacy/CloudFreePrivacyNotice.tsx +0 -117
  326. package/dist/ui/privacy/CloudPaidPrivacyNotice.tsx +0 -59
  327. package/dist/ui/privacy/GeminiPrivacyNotice.tsx +0 -62
  328. package/dist/ui/privacy/PrivacyNotice.tsx +0 -42
  329. package/dist/ui/semantic-colors.ts +0 -26
  330. package/dist/ui/themes/ansi-light.ts +0 -150
  331. package/dist/ui/themes/ansi.ts +0 -159
  332. package/dist/ui/themes/atom-one-dark.ts +0 -147
  333. package/dist/ui/themes/ayu-light.ts +0 -139
  334. package/dist/ui/themes/ayu.ts +0 -113
  335. package/dist/ui/themes/color-utils.test.ts +0 -221
  336. package/dist/ui/themes/color-utils.ts +0 -231
  337. package/dist/ui/themes/default-light.ts +0 -108
  338. package/dist/ui/themes/default.ts +0 -151
  339. package/dist/ui/themes/dracula.ts +0 -124
  340. package/dist/ui/themes/fss-code-dark.ts +0 -156
  341. package/dist/ui/themes/fss-dark.ts +0 -113
  342. package/dist/ui/themes/fss-light.ts +0 -139
  343. package/dist/ui/themes/github-dark.ts +0 -147
  344. package/dist/ui/themes/github-light.ts +0 -149
  345. package/dist/ui/themes/googlecode.ts +0 -146
  346. package/dist/ui/themes/no-color.ts +0 -125
  347. package/dist/ui/themes/qwen-dark.ts +0 -118
  348. package/dist/ui/themes/qwen-light.ts +0 -144
  349. package/dist/ui/themes/semantic-tokens.ts +0 -127
  350. package/dist/ui/themes/shades-of-purple.ts +0 -352
  351. package/dist/ui/themes/theme-manager.test.ts +0 -99
  352. package/dist/ui/themes/theme-manager.ts +0 -257
  353. package/dist/ui/themes/theme.test.ts +0 -97
  354. package/dist/ui/themes/theme.ts +0 -451
  355. package/dist/ui/themes/xcode.ts +0 -154
  356. package/dist/ui/types.ts +0 -255
  357. package/dist/ui/utils/CodeColorizer.tsx +0 -217
  358. package/dist/ui/utils/ConsolePatcher.ts +0 -71
  359. package/dist/ui/utils/InlineMarkdownRenderer.tsx +0 -173
  360. package/dist/ui/utils/MarkdownDisplay.test.tsx +0 -244
  361. package/dist/ui/utils/MarkdownDisplay.tsx +0 -415
  362. package/dist/ui/utils/TableRenderer.tsx +0 -159
  363. package/dist/ui/utils/__snapshots__/MarkdownDisplay.test.tsx.snap +0 -93
  364. package/dist/ui/utils/clipboardUtils.test.ts +0 -76
  365. package/dist/ui/utils/clipboardUtils.ts +0 -149
  366. package/dist/ui/utils/commandUtils.test.ts +0 -384
  367. package/dist/ui/utils/commandUtils.ts +0 -106
  368. package/dist/ui/utils/computeStats.test.ts +0 -292
  369. package/dist/ui/utils/computeStats.ts +0 -86
  370. package/dist/ui/utils/displayUtils.test.ts +0 -58
  371. package/dist/ui/utils/displayUtils.ts +0 -32
  372. package/dist/ui/utils/formatters.test.ts +0 -72
  373. package/dist/ui/utils/formatters.ts +0 -63
  374. package/dist/ui/utils/isNarrowWidth.ts +0 -9
  375. package/dist/ui/utils/kittyProtocolDetector.ts +0 -105
  376. package/dist/ui/utils/markdownUtilities.test.ts +0 -50
  377. package/dist/ui/utils/markdownUtilities.ts +0 -125
  378. package/dist/ui/utils/platformConstants.ts +0 -52
  379. package/dist/ui/utils/terminalSetup.ts +0 -342
  380. package/dist/ui/utils/textUtils.ts +0 -40
  381. package/dist/ui/utils/updateCheck.test.ts +0 -163
  382. package/dist/ui/utils/updateCheck.ts +0 -100
  383. package/dist/utils/checks.ts +0 -28
  384. package/dist/utils/cleanup.test.ts +0 -68
  385. package/dist/utils/cleanup.ts +0 -36
  386. package/dist/utils/dialogScopeUtils.ts +0 -64
  387. package/dist/utils/events.ts +0 -14
  388. package/dist/utils/gitUtils.test.ts +0 -149
  389. package/dist/utils/gitUtils.ts +0 -116
  390. package/dist/utils/handleAutoUpdate.test.ts +0 -272
  391. package/dist/utils/handleAutoUpdate.ts +0 -145
  392. package/dist/utils/installationInfo.test.ts +0 -315
  393. package/dist/utils/installationInfo.ts +0 -176
  394. package/dist/utils/package.ts +0 -38
  395. package/dist/utils/readStdin.ts +0 -51
  396. package/dist/utils/resolvePath.ts +0 -21
  397. package/dist/utils/sandbox-macos-permissive-closed.sb +0 -32
  398. package/dist/utils/sandbox-macos-permissive-open.sb +0 -25
  399. package/dist/utils/sandbox-macos-permissive-proxied.sb +0 -37
  400. package/dist/utils/sandbox-macos-restrictive-closed.sb +0 -93
  401. package/dist/utils/sandbox-macos-restrictive-open.sb +0 -96
  402. package/dist/utils/sandbox-macos-restrictive-proxied.sb +0 -98
  403. package/dist/utils/sandbox.ts +0 -962
  404. package/dist/utils/settingsUtils.test.ts +0 -797
  405. package/dist/utils/settingsUtils.ts +0 -489
  406. package/dist/utils/spawnWrapper.ts +0 -9
  407. package/dist/utils/startupWarnings.test.ts +0 -83
  408. package/dist/utils/startupWarnings.ts +0 -40
  409. package/dist/utils/updateEventEmitter.ts +0 -13
  410. package/dist/utils/userStartupWarnings.test.ts +0 -87
  411. package/dist/utils/userStartupWarnings.ts +0 -69
  412. package/dist/utils/version.ts +0 -12
  413. package/dist/validateNonInterActiveAuth.test.ts +0 -260
  414. package/dist/validateNonInterActiveAuth.ts +0 -51
  415. package/dist/vitest.config.ts +0 -37
  416. package/dist/zed-integration/acp.ts +0 -366
  417. package/dist/zed-integration/fileSystemService.ts +0 -47
  418. package/dist/zed-integration/schema.ts +0 -466
  419. package/dist/zed-integration/zedIntegration.ts +0 -944
@@ -1,1691 +0,0 @@
1
- /**
2
- * @license
3
- * Copyright 2025 Google LLC
4
- * SPDX-License-Identifier: Apache-2.0
5
- */
6
-
7
- import { describe, it, expect, vi, beforeEach } from 'vitest';
8
- import { renderHook, act } from '@testing-library/react';
9
- import React from 'react';
10
- import { useVim } from './vim.js';
11
- import type { TextBuffer } from '../components/shared/text-buffer.js';
12
- import { textBufferReducer } from '../components/shared/text-buffer.js';
13
-
14
- // Mock the VimModeContext
15
- const mockVimContext = {
16
- vimEnabled: true,
17
- vimMode: 'NORMAL' as const,
18
- toggleVimEnabled: vi.fn(),
19
- setVimMode: vi.fn(),
20
- };
21
-
22
- vi.mock('../contexts/VimModeContext.js', () => ({
23
- useVimMode: () => mockVimContext,
24
- VimModeProvider: ({ children }: { children: React.ReactNode }) => children,
25
- }));
26
-
27
- // Test constants
28
- const TEST_SEQUENCES = {
29
- ESCAPE: { sequence: '\u001b', name: 'escape' },
30
- LEFT: { sequence: 'h' },
31
- RIGHT: { sequence: 'l' },
32
- UP: { sequence: 'k' },
33
- DOWN: { sequence: 'j' },
34
- INSERT: { sequence: 'i' },
35
- APPEND: { sequence: 'a' },
36
- DELETE_CHAR: { sequence: 'x' },
37
- DELETE: { sequence: 'd' },
38
- CHANGE: { sequence: 'c' },
39
- WORD_FORWARD: { sequence: 'w' },
40
- WORD_BACKWARD: { sequence: 'b' },
41
- WORD_END: { sequence: 'e' },
42
- LINE_START: { sequence: '0' },
43
- LINE_END: { sequence: '$' },
44
- REPEAT: { sequence: '.' },
45
- } as const;
46
-
47
- describe('useVim hook', () => {
48
- let mockBuffer: Partial<TextBuffer>;
49
- let mockHandleFinalSubmit: vi.Mock;
50
-
51
- const createMockBuffer = (
52
- text = 'hello world',
53
- cursor: [number, number] = [0, 5],
54
- ) => {
55
- const cursorState = { pos: cursor };
56
- const lines = text.split('\n');
57
-
58
- return {
59
- lines,
60
- get cursor() {
61
- return cursorState.pos;
62
- },
63
- set cursor(newPos: [number, number]) {
64
- cursorState.pos = newPos;
65
- },
66
- text,
67
- move: vi.fn().mockImplementation((direction: string) => {
68
- let [row, col] = cursorState.pos;
69
- const _line = lines[row] || '';
70
- if (direction === 'left') {
71
- col = Math.max(0, col - 1);
72
- } else if (direction === 'right') {
73
- col = Math.min(line.length, col + 1);
74
- } else if (direction === 'home') {
75
- col = 0;
76
- } else if (direction === 'end') {
77
- col = line.length;
78
- }
79
- cursorState.pos = [row, col];
80
- }),
81
- del: vi.fn(),
82
- moveToOffset: vi.fn(),
83
- insert: vi.fn(),
84
- newline: vi.fn(),
85
- replaceRangeByOffset: vi.fn(),
86
- handleInput: vi.fn(),
87
- setText: vi.fn(),
88
- // Vim-specific methods
89
- vimDeleteWordForward: vi.fn(),
90
- vimDeleteWordBackward: vi.fn(),
91
- vimDeleteWordEnd: vi.fn(),
92
- vimChangeWordForward: vi.fn(),
93
- vimChangeWordBackward: vi.fn(),
94
- vimChangeWordEnd: vi.fn(),
95
- vimDeleteLine: vi.fn(),
96
- vimChangeLine: vi.fn(),
97
- vimDeleteToEndOfLine: vi.fn(),
98
- vimChangeToEndOfLine: vi.fn(),
99
- vimChangeMovement: vi.fn(),
100
- vimMoveLeft: vi.fn(),
101
- vimMoveRight: vi.fn(),
102
- vimMoveUp: vi.fn(),
103
- vimMoveDown: vi.fn(),
104
- vimMoveWordForward: vi.fn(),
105
- vimMoveWordBackward: vi.fn(),
106
- vimMoveWordEnd: vi.fn(),
107
- vimDeleteChar: vi.fn(),
108
- vimInsertAtCursor: vi.fn(),
109
- vimAppendAtCursor: vi.fn().mockImplementation(() => {
110
- // Append moves cursor right (vim 'a' behavior - position after current char)
111
- const [row, col] = cursorState.pos;
112
- const _line = lines[row] || '';
113
- // In vim, 'a' moves cursor to position after current character
114
- // This allows inserting at the end of the line
115
- cursorState.pos = [row, col + 1];
116
- }),
117
- vimOpenLineBelow: vi.fn(),
118
- vimOpenLineAbove: vi.fn(),
119
- vimAppendAtLineEnd: vi.fn(),
120
- vimInsertAtLineStart: vi.fn(),
121
- vimMoveToLineStart: vi.fn(),
122
- vimMoveToLineEnd: vi.fn(),
123
- vimMoveToFirstNonWhitespace: vi.fn(),
124
- vimMoveToFirstLine: vi.fn(),
125
- vimMoveToLastLine: vi.fn(),
126
- vimMoveToLine: vi.fn(),
127
- vimEscapeInsertMode: vi.fn().mockImplementation(() => {
128
- // Escape moves cursor left unless at beginning of line
129
- const [row, col] = cursorState.pos;
130
- if (col > 0) {
131
- cursorState.pos = [row, col - 1];
132
- }
133
- }),
134
- };
135
- };
136
-
137
- const _createMockSettings = (vimMode = true) => ({
138
- getValue: vi.fn().mockReturnValue(vimMode),
139
- setValue: vi.fn(),
140
- merged: { vimMode },
141
- });
142
-
143
- const renderVimHook = (buffer?: Partial<TextBuffer>) =>
144
- renderHook(() =>
145
- useVim((buffer || mockBuffer) as TextBuffer, mockHandleFinalSubmit),
146
- );
147
-
148
- const exitInsertMode = (result: {
149
- current: {
150
- handleInput: (input: { sequence: string; name: string }) => void;
151
- };
152
- }) => {
153
- act(() => {
154
- result.current.handleInput({ sequence: '\u001b', name: 'escape' });
155
- });
156
- };
157
-
158
- beforeEach(() => {
159
- vi.clearAllMocks();
160
- mockHandleFinalSubmit = vi.fn();
161
- mockBuffer = createMockBuffer();
162
- // Reset mock context to default state
163
- mockVimContext.vimEnabled = true;
164
- mockVimContext.vimMode = 'NORMAL';
165
- mockVimContext.toggleVimEnabled.mockClear();
166
- mockVimContext.setVimMode.mockClear();
167
- });
168
-
169
- describe('Mode switching', () => {
170
- it('should start in NORMAL mode', () => {
171
- const { result } = renderVimHook();
172
- expect(result.current.mode).toBe('NORMAL');
173
- });
174
-
175
- it('should switch to INSERT mode with i command', () => {
176
- const { result } = renderVimHook();
177
-
178
- act(() => {
179
- result.current.handleInput(TEST_SEQUENCES.INSERT);
180
- });
181
-
182
- expect(result.current.mode).toBe('INSERT');
183
- expect(mockVimContext.setVimMode).toHaveBeenCalledWith('INSERT');
184
- });
185
-
186
- it('should switch back to NORMAL mode with Escape', () => {
187
- const { result } = renderVimHook();
188
-
189
- act(() => {
190
- result.current.handleInput(TEST_SEQUENCES.INSERT);
191
- });
192
- expect(result.current.mode).toBe('INSERT');
193
-
194
- exitInsertMode(result);
195
- expect(result.current.mode).toBe('NORMAL');
196
- });
197
-
198
- it('should properly handle escape followed immediately by a command', () => {
199
- const testBuffer = createMockBuffer('hello world test', [0, 6]);
200
- const { result } = renderVimHook(testBuffer);
201
-
202
- act(() => {
203
- result.current.handleInput({ sequence: 'i' });
204
- });
205
- expect(result.current.mode).toBe('INSERT');
206
-
207
- vi.clearAllMocks();
208
-
209
- exitInsertMode(result);
210
- expect(result.current.mode).toBe('NORMAL');
211
-
212
- act(() => {
213
- result.current.handleInput({ sequence: 'b' });
214
- });
215
-
216
- expect(testBuffer.vimMoveWordBackward).toHaveBeenCalledWith(1);
217
- });
218
- });
219
-
220
- describe('Navigation commands', () => {
221
- it('should handle h (left movement)', () => {
222
- const { result } = renderVimHook();
223
-
224
- act(() => {
225
- result.current.handleInput({ sequence: 'h' });
226
- });
227
-
228
- expect(mockBuffer.vimMoveLeft).toHaveBeenCalledWith(1);
229
- });
230
-
231
- it('should handle l (right movement)', () => {
232
- const { result } = renderVimHook();
233
-
234
- act(() => {
235
- result.current.handleInput({ sequence: 'l' });
236
- });
237
-
238
- expect(mockBuffer.vimMoveRight).toHaveBeenCalledWith(1);
239
- });
240
-
241
- it('should handle j (down movement)', () => {
242
- const testBuffer = createMockBuffer('first line\nsecond line');
243
- const { result } = renderVimHook(testBuffer);
244
-
245
- act(() => {
246
- result.current.handleInput({ sequence: 'j' });
247
- });
248
-
249
- expect(testBuffer.vimMoveDown).toHaveBeenCalledWith(1);
250
- });
251
-
252
- it('should handle k (up movement)', () => {
253
- const testBuffer = createMockBuffer('first line\nsecond line');
254
- const { result } = renderVimHook(testBuffer);
255
-
256
- act(() => {
257
- result.current.handleInput({ sequence: 'k' });
258
- });
259
-
260
- expect(testBuffer.vimMoveUp).toHaveBeenCalledWith(1);
261
- });
262
-
263
- it('should handle 0 (move to start of line)', () => {
264
- const { result } = renderVimHook();
265
-
266
- act(() => {
267
- result.current.handleInput({ sequence: '0' });
268
- });
269
-
270
- expect(mockBuffer.vimMoveToLineStart).toHaveBeenCalled();
271
- });
272
-
273
- it('should handle $ (move to end of line)', () => {
274
- const { result } = renderVimHook();
275
-
276
- act(() => {
277
- result.current.handleInput({ sequence: '$' });
278
- });
279
-
280
- expect(mockBuffer.vimMoveToLineEnd).toHaveBeenCalled();
281
- });
282
- });
283
-
284
- describe('Mode switching commands', () => {
285
- it('should handle a (append after cursor)', () => {
286
- const { result } = renderVimHook();
287
-
288
- act(() => {
289
- result.current.handleInput({ sequence: 'a' });
290
- });
291
-
292
- expect(mockBuffer.vimAppendAtCursor).toHaveBeenCalled();
293
- expect(result.current.mode).toBe('INSERT');
294
- });
295
-
296
- it('should handle A (append at end of line)', () => {
297
- const { result } = renderVimHook();
298
-
299
- act(() => {
300
- result.current.handleInput({ sequence: 'A' });
301
- });
302
-
303
- expect(mockBuffer.vimAppendAtLineEnd).toHaveBeenCalled();
304
- expect(result.current.mode).toBe('INSERT');
305
- });
306
-
307
- it('should handle o (open line below)', () => {
308
- const { result } = renderVimHook();
309
-
310
- act(() => {
311
- result.current.handleInput({ sequence: 'o' });
312
- });
313
-
314
- expect(mockBuffer.vimOpenLineBelow).toHaveBeenCalled();
315
- expect(result.current.mode).toBe('INSERT');
316
- });
317
-
318
- it('should handle O (open line above)', () => {
319
- const { result } = renderVimHook();
320
-
321
- act(() => {
322
- result.current.handleInput({ sequence: 'O' });
323
- });
324
-
325
- expect(mockBuffer.vimOpenLineAbove).toHaveBeenCalled();
326
- expect(result.current.mode).toBe('INSERT');
327
- });
328
- });
329
-
330
- describe('Edit commands', () => {
331
- it('should handle x (delete character)', () => {
332
- const { result } = renderVimHook();
333
- vi.clearAllMocks();
334
-
335
- act(() => {
336
- result.current.handleInput({ sequence: 'x' });
337
- });
338
-
339
- expect(mockBuffer.vimDeleteChar).toHaveBeenCalledWith(1);
340
- });
341
-
342
- it('should move cursor left when deleting last character on line (vim behavior)', () => {
343
- const testBuffer = createMockBuffer('hello', [0, 4]);
344
- const { result } = renderVimHook(testBuffer);
345
-
346
- act(() => {
347
- result.current.handleInput({ sequence: 'x' });
348
- });
349
-
350
- expect(testBuffer.vimDeleteChar).toHaveBeenCalledWith(1);
351
- });
352
-
353
- it('should handle first d key (sets pending state)', () => {
354
- const { result } = renderVimHook();
355
-
356
- act(() => {
357
- result.current.handleInput({ sequence: 'd' });
358
- });
359
-
360
- expect(mockBuffer.replaceRangeByOffset).not.toHaveBeenCalled();
361
- });
362
- });
363
-
364
- describe('Count handling', () => {
365
- it('should handle count input and return to count 0 after command', () => {
366
- const { result } = renderVimHook();
367
-
368
- act(() => {
369
- const handled = result.current.handleInput({ sequence: '3' });
370
- expect(handled).toBe(true);
371
- });
372
-
373
- act(() => {
374
- const handled = result.current.handleInput({ sequence: 'h' });
375
- expect(handled).toBe(true);
376
- });
377
-
378
- expect(mockBuffer.vimMoveLeft).toHaveBeenCalledWith(3);
379
- });
380
-
381
- it('should only delete 1 character with x command when no count is specified', () => {
382
- const testBuffer = createMockBuffer();
383
- const { result } = renderVimHook(testBuffer);
384
-
385
- act(() => {
386
- result.current.handleInput({ sequence: 'x' });
387
- });
388
-
389
- expect(testBuffer.vimDeleteChar).toHaveBeenCalledWith(1);
390
- });
391
- });
392
-
393
- describe('Word movement', () => {
394
- it('should properly initialize vim hook with word movement support', () => {
395
- const testBuffer = createMockBuffer('cat elephant mouse', [0, 0]);
396
- const { result } = renderVimHook(testBuffer);
397
-
398
- expect(result.current.vimModeEnabled).toBe(true);
399
- expect(result.current.mode).toBe('NORMAL');
400
- expect(result.current.handleInput).toBeDefined();
401
- });
402
-
403
- it('should support vim mode and basic operations across multiple lines', () => {
404
- const testBuffer = createMockBuffer(
405
- 'first line word\nsecond line word',
406
- [0, 11],
407
- );
408
- const { result } = renderVimHook(testBuffer);
409
-
410
- expect(result.current.vimModeEnabled).toBe(true);
411
- expect(result.current.mode).toBe('NORMAL');
412
- expect(result.current.handleInput).toBeDefined();
413
- expect(testBuffer.replaceRangeByOffset).toBeDefined();
414
- expect(testBuffer.moveToOffset).toBeDefined();
415
- });
416
-
417
- it('should handle w (next word)', () => {
418
- const testBuffer = createMockBuffer('hello world test');
419
- const { result } = renderVimHook(testBuffer);
420
-
421
- act(() => {
422
- result.current.handleInput({ sequence: 'w' });
423
- });
424
-
425
- expect(testBuffer.vimMoveWordForward).toHaveBeenCalledWith(1);
426
- });
427
-
428
- it('should handle b (previous word)', () => {
429
- const testBuffer = createMockBuffer('hello world test', [0, 6]);
430
- const { result } = renderVimHook(testBuffer);
431
-
432
- act(() => {
433
- result.current.handleInput({ sequence: 'b' });
434
- });
435
-
436
- expect(testBuffer.vimMoveWordBackward).toHaveBeenCalledWith(1);
437
- });
438
-
439
- it('should handle e (end of word)', () => {
440
- const testBuffer = createMockBuffer('hello world test');
441
- const { result } = renderVimHook(testBuffer);
442
-
443
- act(() => {
444
- result.current.handleInput({ sequence: 'e' });
445
- });
446
-
447
- expect(testBuffer.vimMoveWordEnd).toHaveBeenCalledWith(1);
448
- });
449
-
450
- it('should handle w when cursor is on the last word', () => {
451
- const testBuffer = createMockBuffer('hello world', [0, 8]);
452
- const { result } = renderVimHook(testBuffer);
453
-
454
- act(() => {
455
- result.current.handleInput({ sequence: 'w' });
456
- });
457
-
458
- expect(testBuffer.vimMoveWordForward).toHaveBeenCalledWith(1);
459
- });
460
-
461
- it('should handle first c key (sets pending change state)', () => {
462
- const { result } = renderVimHook();
463
-
464
- act(() => {
465
- result.current.handleInput({ sequence: 'c' });
466
- });
467
-
468
- expect(result.current.mode).toBe('NORMAL');
469
- expect(mockBuffer.del).not.toHaveBeenCalled();
470
- });
471
-
472
- it('should clear pending state on invalid command sequence (df)', () => {
473
- const { result } = renderVimHook();
474
-
475
- act(() => {
476
- result.current.handleInput({ sequence: 'd' });
477
- result.current.handleInput({ sequence: 'f' });
478
- });
479
-
480
- expect(mockBuffer.replaceRangeByOffset).not.toHaveBeenCalled();
481
- expect(mockBuffer.del).not.toHaveBeenCalled();
482
- });
483
-
484
- it('should clear pending state with Escape in NORMAL mode', () => {
485
- const { result } = renderVimHook();
486
-
487
- act(() => {
488
- result.current.handleInput({ sequence: 'd' });
489
- });
490
-
491
- exitInsertMode(result);
492
-
493
- expect(mockBuffer.replaceRangeByOffset).not.toHaveBeenCalled();
494
- });
495
- });
496
-
497
- describe('Disabled vim mode', () => {
498
- it('should not respond to vim commands when disabled', () => {
499
- mockVimContext.vimEnabled = false;
500
- const { result } = renderVimHook(mockBuffer);
501
-
502
- act(() => {
503
- result.current.handleInput({ sequence: 'h' });
504
- });
505
-
506
- expect(mockBuffer.move).not.toHaveBeenCalled();
507
- });
508
- });
509
-
510
- // These tests are no longer applicable at the hook level
511
-
512
- describe('Command repeat system', () => {
513
- it('should repeat x command from current cursor position', () => {
514
- const testBuffer = createMockBuffer('abcd\nefgh\nijkl', [0, 1]);
515
- const { result } = renderVimHook(testBuffer);
516
-
517
- act(() => {
518
- result.current.handleInput({ sequence: 'x' });
519
- });
520
- expect(testBuffer.vimDeleteChar).toHaveBeenCalledWith(1);
521
-
522
- testBuffer.cursor = [1, 2];
523
-
524
- act(() => {
525
- result.current.handleInput({ sequence: '.' });
526
- });
527
- expect(testBuffer.vimDeleteChar).toHaveBeenCalledWith(1);
528
- });
529
-
530
- it('should repeat dd command from current position', () => {
531
- const testBuffer = createMockBuffer('line1\nline2\nline3', [1, 0]);
532
- const { result } = renderVimHook(testBuffer);
533
-
534
- act(() => {
535
- result.current.handleInput({ sequence: 'd' });
536
- });
537
- act(() => {
538
- result.current.handleInput({ sequence: 'd' });
539
- });
540
- expect(testBuffer.vimDeleteLine).toHaveBeenCalledTimes(1);
541
-
542
- testBuffer.cursor = [0, 0];
543
-
544
- act(() => {
545
- result.current.handleInput({ sequence: '.' });
546
- });
547
-
548
- expect(testBuffer.vimDeleteLine).toHaveBeenCalledTimes(2);
549
- });
550
-
551
- it('should repeat ce command from current position', () => {
552
- const testBuffer = createMockBuffer('word', [0, 0]);
553
- const { result } = renderVimHook(testBuffer);
554
-
555
- act(() => {
556
- result.current.handleInput({ sequence: 'c' });
557
- });
558
- act(() => {
559
- result.current.handleInput({ sequence: 'e' });
560
- });
561
- expect(testBuffer.vimChangeWordEnd).toHaveBeenCalledTimes(1);
562
-
563
- // Exit INSERT mode to complete the command
564
- exitInsertMode(result);
565
-
566
- testBuffer.cursor = [0, 2];
567
-
568
- act(() => {
569
- result.current.handleInput({ sequence: '.' });
570
- });
571
-
572
- expect(testBuffer.vimChangeWordEnd).toHaveBeenCalledTimes(2);
573
- });
574
-
575
- it('should repeat cc command from current position', () => {
576
- const testBuffer = createMockBuffer('line1\nline2\nline3', [1, 2]);
577
- const { result } = renderVimHook(testBuffer);
578
-
579
- act(() => {
580
- result.current.handleInput({ sequence: 'c' });
581
- });
582
- act(() => {
583
- result.current.handleInput({ sequence: 'c' });
584
- });
585
- expect(testBuffer.vimChangeLine).toHaveBeenCalledTimes(1);
586
-
587
- // Exit INSERT mode to complete the command
588
- exitInsertMode(result);
589
-
590
- testBuffer.cursor = [0, 1];
591
-
592
- act(() => {
593
- result.current.handleInput({ sequence: '.' });
594
- });
595
-
596
- expect(testBuffer.vimChangeLine).toHaveBeenCalledTimes(2);
597
- });
598
-
599
- it('should repeat cw command from current position', () => {
600
- const testBuffer = createMockBuffer('hello world test', [0, 6]);
601
- const { result } = renderVimHook(testBuffer);
602
-
603
- act(() => {
604
- result.current.handleInput({ sequence: 'c' });
605
- });
606
- act(() => {
607
- result.current.handleInput({ sequence: 'w' });
608
- });
609
- expect(testBuffer.vimChangeWordForward).toHaveBeenCalledTimes(1);
610
-
611
- // Exit INSERT mode to complete the command
612
- exitInsertMode(result);
613
-
614
- testBuffer.cursor = [0, 0];
615
-
616
- act(() => {
617
- result.current.handleInput({ sequence: '.' });
618
- });
619
-
620
- expect(testBuffer.vimChangeWordForward).toHaveBeenCalledTimes(2);
621
- });
622
-
623
- it('should repeat D command from current position', () => {
624
- const testBuffer = createMockBuffer('hello world test', [0, 6]);
625
- const { result } = renderVimHook(testBuffer);
626
-
627
- act(() => {
628
- result.current.handleInput({ sequence: 'D' });
629
- });
630
- expect(testBuffer.vimDeleteToEndOfLine).toHaveBeenCalledTimes(1);
631
-
632
- testBuffer.cursor = [0, 2];
633
- vi.clearAllMocks(); // Clear all mocks instead of just one method
634
-
635
- act(() => {
636
- result.current.handleInput({ sequence: '.' });
637
- });
638
-
639
- expect(testBuffer.vimDeleteToEndOfLine).toHaveBeenCalledTimes(1);
640
- });
641
-
642
- it('should repeat C command from current position', () => {
643
- const testBuffer = createMockBuffer('hello world test', [0, 6]);
644
- const { result } = renderVimHook(testBuffer);
645
-
646
- act(() => {
647
- result.current.handleInput({ sequence: 'C' });
648
- });
649
- expect(testBuffer.vimChangeToEndOfLine).toHaveBeenCalledTimes(1);
650
-
651
- // Exit INSERT mode to complete the command
652
- exitInsertMode(result);
653
-
654
- testBuffer.cursor = [0, 2];
655
-
656
- act(() => {
657
- result.current.handleInput({ sequence: '.' });
658
- });
659
-
660
- expect(testBuffer.vimChangeToEndOfLine).toHaveBeenCalledTimes(2);
661
- });
662
-
663
- it('should repeat command after cursor movement', () => {
664
- const testBuffer = createMockBuffer('test text', [0, 0]);
665
- const { result } = renderVimHook(testBuffer);
666
-
667
- act(() => {
668
- result.current.handleInput({ sequence: 'x' });
669
- });
670
- expect(testBuffer.vimDeleteChar).toHaveBeenCalledWith(1);
671
-
672
- testBuffer.cursor = [0, 2];
673
-
674
- act(() => {
675
- result.current.handleInput({ sequence: '.' });
676
- });
677
- expect(testBuffer.vimDeleteChar).toHaveBeenCalledWith(1);
678
- });
679
-
680
- it('should move cursor to the correct position after exiting INSERT mode with "a"', () => {
681
- const testBuffer = createMockBuffer('hello world', [0, 10]);
682
- const { result } = renderVimHook(testBuffer);
683
-
684
- act(() => {
685
- result.current.handleInput({ sequence: 'a' });
686
- });
687
- expect(result.current.mode).toBe('INSERT');
688
- expect(testBuffer.cursor).toEqual([0, 11]);
689
-
690
- exitInsertMode(result);
691
- expect(result.current.mode).toBe('NORMAL');
692
- expect(testBuffer.cursor).toEqual([0, 10]);
693
- });
694
- });
695
-
696
- describe('Special characters and edge cases', () => {
697
- it('should handle ^ (move to first non-whitespace character)', () => {
698
- const testBuffer = createMockBuffer(' hello world', [0, 5]);
699
- const { result } = renderVimHook(testBuffer);
700
-
701
- act(() => {
702
- result.current.handleInput({ sequence: '^' });
703
- });
704
-
705
- expect(testBuffer.vimMoveToFirstNonWhitespace).toHaveBeenCalled();
706
- });
707
-
708
- it('should handle G without count (go to last line)', () => {
709
- const testBuffer = createMockBuffer('line1\nline2\nline3', [0, 0]);
710
- const { result } = renderVimHook(testBuffer);
711
-
712
- act(() => {
713
- result.current.handleInput({ sequence: 'G' });
714
- });
715
-
716
- expect(testBuffer.vimMoveToLastLine).toHaveBeenCalled();
717
- });
718
-
719
- it('should handle gg (go to first line)', () => {
720
- const testBuffer = createMockBuffer('line1\nline2\nline3', [2, 0]);
721
- const { result } = renderVimHook(testBuffer);
722
-
723
- // First 'g' sets pending state
724
- act(() => {
725
- result.current.handleInput({ sequence: 'g' });
726
- });
727
-
728
- // Second 'g' executes the command
729
- act(() => {
730
- result.current.handleInput({ sequence: 'g' });
731
- });
732
-
733
- expect(testBuffer.vimMoveToFirstLine).toHaveBeenCalled();
734
- });
735
-
736
- it('should handle count with movement commands', () => {
737
- const testBuffer = createMockBuffer('hello world test', [0, 0]);
738
- const { result } = renderVimHook(testBuffer);
739
-
740
- act(() => {
741
- result.current.handleInput({ sequence: '3' });
742
- });
743
-
744
- act(() => {
745
- result.current.handleInput(TEST_SEQUENCES.WORD_FORWARD);
746
- });
747
-
748
- expect(testBuffer.vimMoveWordForward).toHaveBeenCalledWith(3);
749
- });
750
- });
751
-
752
- describe('Vim word operations', () => {
753
- describe('dw (delete word forward)', () => {
754
- it('should delete from cursor to start of next word', () => {
755
- const testBuffer = createMockBuffer('hello world test', [0, 0]);
756
- const { result } = renderVimHook(testBuffer);
757
-
758
- act(() => {
759
- result.current.handleInput({ sequence: 'd' });
760
- });
761
- act(() => {
762
- result.current.handleInput({ sequence: 'w' });
763
- });
764
-
765
- expect(testBuffer.vimDeleteWordForward).toHaveBeenCalledWith(1);
766
- });
767
-
768
- it('should actually delete the complete word including trailing space', () => {
769
- // This test uses the real text-buffer reducer instead of mocks
770
- const initialState = {
771
- lines: ['hello world test'],
772
- cursorRow: 0,
773
- cursorCol: 0,
774
- preferredCol: null,
775
- undoStack: [],
776
- redoStack: [],
777
- clipboard: null,
778
- selectionAnchor: null,
779
- };
780
-
781
- const result = textBufferReducer(initialState, {
782
- type: 'vim_delete_word_forward',
783
- payload: { count: 1 },
784
- });
785
-
786
- // Should delete "hello " (word + space), leaving "world test"
787
- expect(result.lines).toEqual(['world test']);
788
- expect(result.cursorRow).toBe(0);
789
- expect(result.cursorCol).toBe(0);
790
- });
791
-
792
- it('should delete word from middle of word correctly', () => {
793
- const initialState = {
794
- lines: ['hello world test'],
795
- cursorRow: 0,
796
- cursorCol: 2, // cursor on 'l' in "hello"
797
- preferredCol: null,
798
- undoStack: [],
799
- redoStack: [],
800
- clipboard: null,
801
- selectionAnchor: null,
802
- };
803
-
804
- const result = textBufferReducer(initialState, {
805
- type: 'vim_delete_word_forward',
806
- payload: { count: 1 },
807
- });
808
-
809
- // Should delete "llo " (rest of word + space), leaving "he world test"
810
- expect(result.lines).toEqual(['heworld test']);
811
- expect(result.cursorRow).toBe(0);
812
- expect(result.cursorCol).toBe(2);
813
- });
814
-
815
- it('should handle dw at end of line', () => {
816
- const initialState = {
817
- lines: ['hello world'],
818
- cursorRow: 0,
819
- cursorCol: 6, // cursor on 'w' in "world"
820
- preferredCol: null,
821
- undoStack: [],
822
- redoStack: [],
823
- clipboard: null,
824
- selectionAnchor: null,
825
- };
826
-
827
- const result = textBufferReducer(initialState, {
828
- type: 'vim_delete_word_forward',
829
- payload: { count: 1 },
830
- });
831
-
832
- // Should delete "world" (no trailing space at end), leaving "hello "
833
- expect(result.lines).toEqual(['hello ']);
834
- expect(result.cursorRow).toBe(0);
835
- expect(result.cursorCol).toBe(6);
836
- });
837
-
838
- it('should delete multiple words with count', () => {
839
- const testBuffer = createMockBuffer('one two three four', [0, 0]);
840
- const { result } = renderVimHook(testBuffer);
841
-
842
- act(() => {
843
- result.current.handleInput({ sequence: '2' });
844
- });
845
- act(() => {
846
- result.current.handleInput({ sequence: 'd' });
847
- });
848
- act(() => {
849
- result.current.handleInput({ sequence: 'w' });
850
- });
851
-
852
- expect(testBuffer.vimDeleteWordForward).toHaveBeenCalledWith(2);
853
- });
854
-
855
- it('should record command for repeat with dot', () => {
856
- const testBuffer = createMockBuffer('hello world test', [0, 0]);
857
- const { result } = renderVimHook(testBuffer);
858
-
859
- // Execute dw
860
- act(() => {
861
- result.current.handleInput({ sequence: 'd' });
862
- });
863
- act(() => {
864
- result.current.handleInput({ sequence: 'w' });
865
- });
866
-
867
- vi.clearAllMocks();
868
-
869
- // Execute dot repeat
870
- act(() => {
871
- result.current.handleInput({ sequence: '.' });
872
- });
873
-
874
- expect(testBuffer.vimDeleteWordForward).toHaveBeenCalledWith(1);
875
- });
876
- });
877
-
878
- describe('de (delete word end)', () => {
879
- it('should delete from cursor to end of current word', () => {
880
- const testBuffer = createMockBuffer('hello world test', [0, 1]);
881
- const { result } = renderVimHook(testBuffer);
882
-
883
- act(() => {
884
- result.current.handleInput({ sequence: 'd' });
885
- });
886
- act(() => {
887
- result.current.handleInput({ sequence: 'e' });
888
- });
889
-
890
- expect(testBuffer.vimDeleteWordEnd).toHaveBeenCalledWith(1);
891
- });
892
-
893
- it('should handle count with de', () => {
894
- const testBuffer = createMockBuffer('one two three four', [0, 0]);
895
- const { result } = renderVimHook(testBuffer);
896
-
897
- act(() => {
898
- result.current.handleInput({ sequence: '3' });
899
- });
900
- act(() => {
901
- result.current.handleInput({ sequence: 'd' });
902
- });
903
- act(() => {
904
- result.current.handleInput({ sequence: 'e' });
905
- });
906
-
907
- expect(testBuffer.vimDeleteWordEnd).toHaveBeenCalledWith(3);
908
- });
909
- });
910
-
911
- describe('cw (change word forward)', () => {
912
- it('should change from cursor to start of next word and enter INSERT mode', () => {
913
- const testBuffer = createMockBuffer('hello world test', [0, 0]);
914
- const { result } = renderVimHook(testBuffer);
915
-
916
- act(() => {
917
- result.current.handleInput({ sequence: 'c' });
918
- });
919
- act(() => {
920
- result.current.handleInput({ sequence: 'w' });
921
- });
922
-
923
- expect(testBuffer.vimChangeWordForward).toHaveBeenCalledWith(1);
924
- expect(result.current.mode).toBe('INSERT');
925
- expect(mockVimContext.setVimMode).toHaveBeenCalledWith('INSERT');
926
- });
927
-
928
- it('should handle count with cw', () => {
929
- const testBuffer = createMockBuffer('one two three four', [0, 0]);
930
- const { result } = renderVimHook(testBuffer);
931
-
932
- act(() => {
933
- result.current.handleInput({ sequence: '2' });
934
- });
935
- act(() => {
936
- result.current.handleInput({ sequence: 'c' });
937
- });
938
- act(() => {
939
- result.current.handleInput({ sequence: 'w' });
940
- });
941
-
942
- expect(testBuffer.vimChangeWordForward).toHaveBeenCalledWith(2);
943
- expect(result.current.mode).toBe('INSERT');
944
- });
945
-
946
- it('should be repeatable with dot', () => {
947
- const testBuffer = createMockBuffer('hello world test more', [0, 0]);
948
- const { result } = renderVimHook(testBuffer);
949
-
950
- // Execute cw
951
- act(() => {
952
- result.current.handleInput({ sequence: 'c' });
953
- });
954
- act(() => {
955
- result.current.handleInput({ sequence: 'w' });
956
- });
957
-
958
- // Exit INSERT mode
959
- exitInsertMode(result);
960
-
961
- vi.clearAllMocks();
962
- mockVimContext.setVimMode.mockClear();
963
-
964
- // Execute dot repeat
965
- act(() => {
966
- result.current.handleInput({ sequence: '.' });
967
- });
968
-
969
- expect(testBuffer.vimChangeWordForward).toHaveBeenCalledWith(1);
970
- expect(result.current.mode).toBe('INSERT');
971
- });
972
- });
973
-
974
- describe('ce (change word end)', () => {
975
- it('should change from cursor to end of word and enter INSERT mode', () => {
976
- const testBuffer = createMockBuffer('hello world test', [0, 1]);
977
- const { result } = renderVimHook(testBuffer);
978
-
979
- act(() => {
980
- result.current.handleInput({ sequence: 'c' });
981
- });
982
- act(() => {
983
- result.current.handleInput({ sequence: 'e' });
984
- });
985
-
986
- expect(testBuffer.vimChangeWordEnd).toHaveBeenCalledWith(1);
987
- expect(result.current.mode).toBe('INSERT');
988
- });
989
-
990
- it('should handle count with ce', () => {
991
- const testBuffer = createMockBuffer('one two three four', [0, 0]);
992
- const { result } = renderVimHook(testBuffer);
993
-
994
- act(() => {
995
- result.current.handleInput({ sequence: '2' });
996
- });
997
- act(() => {
998
- result.current.handleInput({ sequence: 'c' });
999
- });
1000
- act(() => {
1001
- result.current.handleInput({ sequence: 'e' });
1002
- });
1003
-
1004
- expect(testBuffer.vimChangeWordEnd).toHaveBeenCalledWith(2);
1005
- expect(result.current.mode).toBe('INSERT');
1006
- });
1007
- });
1008
-
1009
- describe('cc (change line)', () => {
1010
- it('should change entire line and enter INSERT mode', () => {
1011
- const testBuffer = createMockBuffer('hello world\nsecond line', [0, 5]);
1012
- const { result } = renderVimHook(testBuffer);
1013
-
1014
- act(() => {
1015
- result.current.handleInput({ sequence: 'c' });
1016
- });
1017
- act(() => {
1018
- result.current.handleInput({ sequence: 'c' });
1019
- });
1020
-
1021
- expect(testBuffer.vimChangeLine).toHaveBeenCalledWith(1);
1022
- expect(result.current.mode).toBe('INSERT');
1023
- });
1024
-
1025
- it('should change multiple lines with count', () => {
1026
- const testBuffer = createMockBuffer(
1027
- 'line1\nline2\nline3\nline4',
1028
- [1, 0],
1029
- );
1030
- const { result } = renderVimHook(testBuffer);
1031
-
1032
- act(() => {
1033
- result.current.handleInput({ sequence: '3' });
1034
- });
1035
- act(() => {
1036
- result.current.handleInput({ sequence: 'c' });
1037
- });
1038
- act(() => {
1039
- result.current.handleInput({ sequence: 'c' });
1040
- });
1041
-
1042
- expect(testBuffer.vimChangeLine).toHaveBeenCalledWith(3);
1043
- expect(result.current.mode).toBe('INSERT');
1044
- });
1045
-
1046
- it('should be repeatable with dot', () => {
1047
- const testBuffer = createMockBuffer('line1\nline2\nline3', [0, 0]);
1048
- const { result } = renderVimHook(testBuffer);
1049
-
1050
- // Execute cc
1051
- act(() => {
1052
- result.current.handleInput({ sequence: 'c' });
1053
- });
1054
- act(() => {
1055
- result.current.handleInput({ sequence: 'c' });
1056
- });
1057
-
1058
- // Exit INSERT mode
1059
- exitInsertMode(result);
1060
-
1061
- vi.clearAllMocks();
1062
- mockVimContext.setVimMode.mockClear();
1063
-
1064
- // Execute dot repeat
1065
- act(() => {
1066
- result.current.handleInput({ sequence: '.' });
1067
- });
1068
-
1069
- expect(testBuffer.vimChangeLine).toHaveBeenCalledWith(1);
1070
- expect(result.current.mode).toBe('INSERT');
1071
- });
1072
- });
1073
-
1074
- describe('db (delete word backward)', () => {
1075
- it('should delete from cursor to start of previous word', () => {
1076
- const testBuffer = createMockBuffer('hello world test', [0, 11]);
1077
- const { result } = renderVimHook(testBuffer);
1078
-
1079
- act(() => {
1080
- result.current.handleInput({ sequence: 'd' });
1081
- });
1082
- act(() => {
1083
- result.current.handleInput({ sequence: 'b' });
1084
- });
1085
-
1086
- expect(testBuffer.vimDeleteWordBackward).toHaveBeenCalledWith(1);
1087
- });
1088
-
1089
- it('should handle count with db', () => {
1090
- const testBuffer = createMockBuffer('one two three four', [0, 18]);
1091
- const { result } = renderVimHook(testBuffer);
1092
-
1093
- act(() => {
1094
- result.current.handleInput({ sequence: '2' });
1095
- });
1096
- act(() => {
1097
- result.current.handleInput({ sequence: 'd' });
1098
- });
1099
- act(() => {
1100
- result.current.handleInput({ sequence: 'b' });
1101
- });
1102
-
1103
- expect(testBuffer.vimDeleteWordBackward).toHaveBeenCalledWith(2);
1104
- });
1105
- });
1106
-
1107
- describe('cb (change word backward)', () => {
1108
- it('should change from cursor to start of previous word and enter INSERT mode', () => {
1109
- const testBuffer = createMockBuffer('hello world test', [0, 11]);
1110
- const { result } = renderVimHook(testBuffer);
1111
-
1112
- act(() => {
1113
- result.current.handleInput({ sequence: 'c' });
1114
- });
1115
- act(() => {
1116
- result.current.handleInput({ sequence: 'b' });
1117
- });
1118
-
1119
- expect(testBuffer.vimChangeWordBackward).toHaveBeenCalledWith(1);
1120
- expect(result.current.mode).toBe('INSERT');
1121
- });
1122
-
1123
- it('should handle count with cb', () => {
1124
- const testBuffer = createMockBuffer('one two three four', [0, 18]);
1125
- const { result } = renderVimHook(testBuffer);
1126
-
1127
- act(() => {
1128
- result.current.handleInput({ sequence: '3' });
1129
- });
1130
- act(() => {
1131
- result.current.handleInput({ sequence: 'c' });
1132
- });
1133
- act(() => {
1134
- result.current.handleInput({ sequence: 'b' });
1135
- });
1136
-
1137
- expect(testBuffer.vimChangeWordBackward).toHaveBeenCalledWith(3);
1138
- expect(result.current.mode).toBe('INSERT');
1139
- });
1140
- });
1141
-
1142
- describe('Pending state handling', () => {
1143
- it('should clear pending delete state after dw', () => {
1144
- const testBuffer = createMockBuffer('hello world', [0, 0]);
1145
- const { result } = renderVimHook(testBuffer);
1146
-
1147
- // Press 'd' to enter pending delete state
1148
- act(() => {
1149
- result.current.handleInput({ sequence: 'd' });
1150
- });
1151
-
1152
- // Complete with 'w'
1153
- act(() => {
1154
- result.current.handleInput({ sequence: 'w' });
1155
- });
1156
-
1157
- // Next 'd' should start a new pending state, not continue the previous one
1158
- act(() => {
1159
- result.current.handleInput({ sequence: 'd' });
1160
- });
1161
-
1162
- // This should trigger dd (delete line), not an error
1163
- act(() => {
1164
- result.current.handleInput({ sequence: 'd' });
1165
- });
1166
-
1167
- expect(testBuffer.vimDeleteLine).toHaveBeenCalledWith(1);
1168
- });
1169
-
1170
- it('should clear pending change state after cw', () => {
1171
- const testBuffer = createMockBuffer('hello world', [0, 0]);
1172
- const { result } = renderVimHook(testBuffer);
1173
-
1174
- // Execute cw
1175
- act(() => {
1176
- result.current.handleInput({ sequence: 'c' });
1177
- });
1178
- act(() => {
1179
- result.current.handleInput({ sequence: 'w' });
1180
- });
1181
-
1182
- // Exit INSERT mode
1183
- exitInsertMode(result);
1184
-
1185
- // Next 'c' should start a new pending state
1186
- act(() => {
1187
- result.current.handleInput({ sequence: 'c' });
1188
- });
1189
- act(() => {
1190
- result.current.handleInput({ sequence: 'c' });
1191
- });
1192
-
1193
- expect(testBuffer.vimChangeLine).toHaveBeenCalledWith(1);
1194
- });
1195
-
1196
- it('should clear pending state with escape', () => {
1197
- const testBuffer = createMockBuffer('hello world', [0, 0]);
1198
- const { result } = renderVimHook(testBuffer);
1199
-
1200
- // Enter pending delete state
1201
- act(() => {
1202
- result.current.handleInput({ sequence: 'd' });
1203
- });
1204
-
1205
- // Press escape to clear pending state
1206
- act(() => {
1207
- result.current.handleInput({ name: 'escape' });
1208
- });
1209
-
1210
- // Now 'w' should just move cursor, not delete
1211
- act(() => {
1212
- result.current.handleInput({ sequence: 'w' });
1213
- });
1214
-
1215
- expect(testBuffer.vimDeleteWordForward).not.toHaveBeenCalled();
1216
- // w should move to next word after clearing pending state
1217
- expect(testBuffer.vimMoveWordForward).toHaveBeenCalledWith(1);
1218
- });
1219
- });
1220
-
1221
- describe('NORMAL mode escape behavior', () => {
1222
- it('should pass escape through when no pending operator is active', () => {
1223
- mockVimContext.vimMode = 'NORMAL';
1224
- const { result } = renderVimHook();
1225
-
1226
- const handled = result.current.handleInput({ name: 'escape' });
1227
-
1228
- expect(handled).toBe(false);
1229
- });
1230
-
1231
- it('should handle escape and clear pending operator', () => {
1232
- mockVimContext.vimMode = 'NORMAL';
1233
- const { result } = renderVimHook();
1234
-
1235
- act(() => {
1236
- result.current.handleInput({ sequence: 'd' });
1237
- });
1238
-
1239
- let handled: boolean | undefined;
1240
- act(() => {
1241
- handled = result.current.handleInput({ name: 'escape' });
1242
- });
1243
-
1244
- expect(handled).toBe(true);
1245
- });
1246
- });
1247
- });
1248
-
1249
- describe('Shell command pass-through', () => {
1250
- it('should pass through ctrl+r in INSERT mode', () => {
1251
- mockVimContext.vimMode = 'INSERT';
1252
- const { result } = renderVimHook();
1253
-
1254
- const handled = result.current.handleInput({ name: 'r', ctrl: true });
1255
-
1256
- expect(handled).toBe(false);
1257
- });
1258
-
1259
- it('should pass through ! in INSERT mode when buffer is empty', () => {
1260
- mockVimContext.vimMode = 'INSERT';
1261
- const emptyBuffer = createMockBuffer('');
1262
- const { result } = renderVimHook(emptyBuffer);
1263
-
1264
- const handled = result.current.handleInput({ sequence: '!' });
1265
-
1266
- expect(handled).toBe(false);
1267
- });
1268
-
1269
- it('should handle ! as input in INSERT mode when buffer is not empty', () => {
1270
- mockVimContext.vimMode = 'INSERT';
1271
- const nonEmptyBuffer = createMockBuffer('not empty');
1272
- const { result } = renderVimHook(nonEmptyBuffer);
1273
- const key = { sequence: '!', name: '!' };
1274
-
1275
- act(() => {
1276
- result.current.handleInput(key);
1277
- });
1278
-
1279
- expect(nonEmptyBuffer.handleInput).toHaveBeenCalledWith(
1280
- expect.objectContaining(key),
1281
- );
1282
- });
1283
- });
1284
-
1285
- // Line operations (dd, cc) are tested in text-buffer.test.ts
1286
-
1287
- describe('Reducer-based integration tests', () => {
1288
- describe('de (delete word end)', () => {
1289
- it('should delete from cursor to end of current word', () => {
1290
- const initialState = {
1291
- lines: ['hello world test'],
1292
- cursorRow: 0,
1293
- cursorCol: 1, // cursor on 'e' in "hello"
1294
- preferredCol: null,
1295
- undoStack: [],
1296
- redoStack: [],
1297
- clipboard: null,
1298
- selectionAnchor: null,
1299
- };
1300
-
1301
- const result = textBufferReducer(initialState, {
1302
- type: 'vim_delete_word_end',
1303
- payload: { count: 1 },
1304
- });
1305
-
1306
- // Should delete "ello" (from cursor to end of word), leaving "h world test"
1307
- expect(result.lines).toEqual(['h world test']);
1308
- expect(result.cursorRow).toBe(0);
1309
- expect(result.cursorCol).toBe(1);
1310
- });
1311
-
1312
- it('should delete multiple word ends with count', () => {
1313
- const initialState = {
1314
- lines: ['hello world test more'],
1315
- cursorRow: 0,
1316
- cursorCol: 1, // cursor on 'e' in "hello"
1317
- preferredCol: null,
1318
- undoStack: [],
1319
- redoStack: [],
1320
- clipboard: null,
1321
- selectionAnchor: null,
1322
- };
1323
-
1324
- const result = textBufferReducer(initialState, {
1325
- type: 'vim_delete_word_end',
1326
- payload: { count: 2 },
1327
- });
1328
-
1329
- // Should delete "ello world" (to end of second word), leaving "h test more"
1330
- expect(result.lines).toEqual(['h test more']);
1331
- expect(result.cursorRow).toBe(0);
1332
- expect(result.cursorCol).toBe(1);
1333
- });
1334
- });
1335
-
1336
- describe('db (delete word backward)', () => {
1337
- it('should delete from cursor to start of previous word', () => {
1338
- const initialState = {
1339
- lines: ['hello world test'],
1340
- cursorRow: 0,
1341
- cursorCol: 11, // cursor on 't' in "test"
1342
- preferredCol: null,
1343
- undoStack: [],
1344
- redoStack: [],
1345
- clipboard: null,
1346
- selectionAnchor: null,
1347
- };
1348
-
1349
- const result = textBufferReducer(initialState, {
1350
- type: 'vim_delete_word_backward',
1351
- payload: { count: 1 },
1352
- });
1353
-
1354
- // Should delete "world" (previous word only), leaving "hello test"
1355
- expect(result.lines).toEqual(['hello test']);
1356
- expect(result.cursorRow).toBe(0);
1357
- expect(result.cursorCol).toBe(6);
1358
- });
1359
-
1360
- it('should delete multiple words backward with count', () => {
1361
- const initialState = {
1362
- lines: ['hello world test more'],
1363
- cursorRow: 0,
1364
- cursorCol: 17, // cursor on 'm' in "more"
1365
- preferredCol: null,
1366
- undoStack: [],
1367
- redoStack: [],
1368
- clipboard: null,
1369
- selectionAnchor: null,
1370
- };
1371
-
1372
- const result = textBufferReducer(initialState, {
1373
- type: 'vim_delete_word_backward',
1374
- payload: { count: 2 },
1375
- });
1376
-
1377
- // Should delete "world test " (two words backward), leaving "hello more"
1378
- expect(result.lines).toEqual(['hello more']);
1379
- expect(result.cursorRow).toBe(0);
1380
- expect(result.cursorCol).toBe(6);
1381
- });
1382
- });
1383
-
1384
- describe('cw (change word forward)', () => {
1385
- it('should delete from cursor to start of next word', () => {
1386
- const initialState = {
1387
- lines: ['hello world test'],
1388
- cursorRow: 0,
1389
- cursorCol: 0, // cursor on 'h' in "hello"
1390
- preferredCol: null,
1391
- undoStack: [],
1392
- redoStack: [],
1393
- clipboard: null,
1394
- selectionAnchor: null,
1395
- };
1396
-
1397
- const result = textBufferReducer(initialState, {
1398
- type: 'vim_change_word_forward',
1399
- payload: { count: 1 },
1400
- });
1401
-
1402
- // Should delete "hello " (word + space), leaving "world test"
1403
- expect(result.lines).toEqual(['world test']);
1404
- expect(result.cursorRow).toBe(0);
1405
- expect(result.cursorCol).toBe(0);
1406
- });
1407
-
1408
- it('should change multiple words with count', () => {
1409
- const initialState = {
1410
- lines: ['hello world test more'],
1411
- cursorRow: 0,
1412
- cursorCol: 0,
1413
- preferredCol: null,
1414
- undoStack: [],
1415
- redoStack: [],
1416
- clipboard: null,
1417
- selectionAnchor: null,
1418
- };
1419
-
1420
- const result = textBufferReducer(initialState, {
1421
- type: 'vim_change_word_forward',
1422
- payload: { count: 2 },
1423
- });
1424
-
1425
- // Should delete "hello world " (two words), leaving "test more"
1426
- expect(result.lines).toEqual(['test more']);
1427
- expect(result.cursorRow).toBe(0);
1428
- expect(result.cursorCol).toBe(0);
1429
- });
1430
- });
1431
-
1432
- describe('ce (change word end)', () => {
1433
- it('should change from cursor to end of current word', () => {
1434
- const initialState = {
1435
- lines: ['hello world test'],
1436
- cursorRow: 0,
1437
- cursorCol: 1, // cursor on 'e' in "hello"
1438
- preferredCol: null,
1439
- undoStack: [],
1440
- redoStack: [],
1441
- clipboard: null,
1442
- selectionAnchor: null,
1443
- };
1444
-
1445
- const result = textBufferReducer(initialState, {
1446
- type: 'vim_change_word_end',
1447
- payload: { count: 1 },
1448
- });
1449
-
1450
- // Should delete "ello" (from cursor to end of word), leaving "h world test"
1451
- expect(result.lines).toEqual(['h world test']);
1452
- expect(result.cursorRow).toBe(0);
1453
- expect(result.cursorCol).toBe(1);
1454
- });
1455
-
1456
- it('should change multiple word ends with count', () => {
1457
- const initialState = {
1458
- lines: ['hello world test'],
1459
- cursorRow: 0,
1460
- cursorCol: 1, // cursor on 'e' in "hello"
1461
- preferredCol: null,
1462
- undoStack: [],
1463
- redoStack: [],
1464
- clipboard: null,
1465
- selectionAnchor: null,
1466
- };
1467
-
1468
- const result = textBufferReducer(initialState, {
1469
- type: 'vim_change_word_end',
1470
- payload: { count: 2 },
1471
- });
1472
-
1473
- // Should delete "ello world" (to end of second word), leaving "h test"
1474
- expect(result.lines).toEqual(['h test']);
1475
- expect(result.cursorRow).toBe(0);
1476
- expect(result.cursorCol).toBe(1);
1477
- });
1478
- });
1479
-
1480
- describe('cb (change word backward)', () => {
1481
- it('should change from cursor to start of previous word', () => {
1482
- const initialState = {
1483
- lines: ['hello world test'],
1484
- cursorRow: 0,
1485
- cursorCol: 11, // cursor on 't' in "test"
1486
- preferredCol: null,
1487
- undoStack: [],
1488
- redoStack: [],
1489
- clipboard: null,
1490
- selectionAnchor: null,
1491
- };
1492
-
1493
- const result = textBufferReducer(initialState, {
1494
- type: 'vim_change_word_backward',
1495
- payload: { count: 1 },
1496
- });
1497
-
1498
- // Should delete "world" (previous word only), leaving "hello test"
1499
- expect(result.lines).toEqual(['hello test']);
1500
- expect(result.cursorRow).toBe(0);
1501
- expect(result.cursorCol).toBe(6);
1502
- });
1503
- });
1504
-
1505
- describe('cc (change line)', () => {
1506
- it('should clear the line and place cursor at the start', () => {
1507
- const initialState = {
1508
- lines: [' hello world'],
1509
- cursorRow: 0,
1510
- cursorCol: 5, // cursor on 'o'
1511
- preferredCol: null,
1512
- undoStack: [],
1513
- redoStack: [],
1514
- clipboard: null,
1515
- selectionAnchor: null,
1516
- };
1517
-
1518
- const result = textBufferReducer(initialState, {
1519
- type: 'vim_change_line',
1520
- payload: { count: 1 },
1521
- });
1522
-
1523
- expect(result.lines).toEqual(['']);
1524
- expect(result.cursorRow).toBe(0);
1525
- expect(result.cursorCol).toBe(0);
1526
- });
1527
- });
1528
-
1529
- describe('dd (delete line)', () => {
1530
- it('should delete the current line', () => {
1531
- const initialState = {
1532
- lines: ['line1', 'line2', 'line3'],
1533
- cursorRow: 1,
1534
- cursorCol: 2,
1535
- preferredCol: null,
1536
- undoStack: [],
1537
- redoStack: [],
1538
- clipboard: null,
1539
- selectionAnchor: null,
1540
- };
1541
-
1542
- const result = textBufferReducer(initialState, {
1543
- type: 'vim_delete_line',
1544
- payload: { count: 1 },
1545
- });
1546
-
1547
- expect(result.lines).toEqual(['line1', 'line3']);
1548
- expect(result.cursorRow).toBe(1);
1549
- expect(result.cursorCol).toBe(0);
1550
- });
1551
-
1552
- it('should delete multiple lines with count', () => {
1553
- const initialState = {
1554
- lines: ['line1', 'line2', 'line3', 'line4'],
1555
- cursorRow: 1,
1556
- cursorCol: 2,
1557
- preferredCol: null,
1558
- undoStack: [],
1559
- redoStack: [],
1560
- clipboard: null,
1561
- selectionAnchor: null,
1562
- };
1563
-
1564
- const result = textBufferReducer(initialState, {
1565
- type: 'vim_delete_line',
1566
- payload: { count: 2 },
1567
- });
1568
-
1569
- // Should delete lines 1 and 2
1570
- expect(result.lines).toEqual(['line1', 'line4']);
1571
- expect(result.cursorRow).toBe(1);
1572
- expect(result.cursorCol).toBe(0);
1573
- });
1574
-
1575
- it('should handle deleting last line', () => {
1576
- const initialState = {
1577
- lines: ['only line'],
1578
- cursorRow: 0,
1579
- cursorCol: 3,
1580
- preferredCol: null,
1581
- undoStack: [],
1582
- redoStack: [],
1583
- clipboard: null,
1584
- selectionAnchor: null,
1585
- };
1586
-
1587
- const result = textBufferReducer(initialState, {
1588
- type: 'vim_delete_line',
1589
- payload: { count: 1 },
1590
- });
1591
-
1592
- // Should leave an empty line when deleting the only line
1593
- expect(result.lines).toEqual(['']);
1594
- expect(result.cursorRow).toBe(0);
1595
- expect(result.cursorCol).toBe(0);
1596
- });
1597
- });
1598
-
1599
- describe('D (delete to end of line)', () => {
1600
- it('should delete from cursor to end of line', () => {
1601
- const initialState = {
1602
- lines: ['hello world test'],
1603
- cursorRow: 0,
1604
- cursorCol: 6, // cursor on 'w' in "world"
1605
- preferredCol: null,
1606
- undoStack: [],
1607
- redoStack: [],
1608
- clipboard: null,
1609
- selectionAnchor: null,
1610
- };
1611
-
1612
- const result = textBufferReducer(initialState, {
1613
- type: 'vim_delete_to_end_of_line',
1614
- });
1615
-
1616
- // Should delete "world test", leaving "hello "
1617
- expect(result.lines).toEqual(['hello ']);
1618
- expect(result.cursorRow).toBe(0);
1619
- expect(result.cursorCol).toBe(6);
1620
- });
1621
-
1622
- it('should handle D at end of line', () => {
1623
- const initialState = {
1624
- lines: ['hello world'],
1625
- cursorRow: 0,
1626
- cursorCol: 11, // cursor at end
1627
- preferredCol: null,
1628
- undoStack: [],
1629
- redoStack: [],
1630
- clipboard: null,
1631
- selectionAnchor: null,
1632
- };
1633
-
1634
- const result = textBufferReducer(initialState, {
1635
- type: 'vim_delete_to_end_of_line',
1636
- });
1637
-
1638
- // Should not change anything when at end of line
1639
- expect(result.lines).toEqual(['hello world']);
1640
- expect(result.cursorRow).toBe(0);
1641
- expect(result.cursorCol).toBe(11);
1642
- });
1643
- });
1644
-
1645
- describe('C (change to end of line)', () => {
1646
- it('should change from cursor to end of line', () => {
1647
- const initialState = {
1648
- lines: ['hello world test'],
1649
- cursorRow: 0,
1650
- cursorCol: 6, // cursor on 'w' in "world"
1651
- preferredCol: null,
1652
- undoStack: [],
1653
- redoStack: [],
1654
- clipboard: null,
1655
- selectionAnchor: null,
1656
- };
1657
-
1658
- const result = textBufferReducer(initialState, {
1659
- type: 'vim_change_to_end_of_line',
1660
- });
1661
-
1662
- // Should delete "world test", leaving "hello "
1663
- expect(result.lines).toEqual(['hello ']);
1664
- expect(result.cursorRow).toBe(0);
1665
- expect(result.cursorCol).toBe(6);
1666
- });
1667
-
1668
- it('should handle C at beginning of line', () => {
1669
- const initialState = {
1670
- lines: ['hello world'],
1671
- cursorRow: 0,
1672
- cursorCol: 0,
1673
- preferredCol: null,
1674
- undoStack: [],
1675
- redoStack: [],
1676
- clipboard: null,
1677
- selectionAnchor: null,
1678
- };
1679
-
1680
- const result = textBufferReducer(initialState, {
1681
- type: 'vim_change_to_end_of_line',
1682
- });
1683
-
1684
- // Should delete entire line content
1685
- expect(result.lines).toEqual(['']);
1686
- expect(result.cursorRow).toBe(0);
1687
- expect(result.cursorCol).toBe(0);
1688
- });
1689
- });
1690
- });
1691
- });