@google/gemini-cli 0.12.0-nightly.20251023.c4c0c0d1 → 0.12.0-nightly.20251027.cb0947c5
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.
- package/dist/package.json +3 -3
- package/dist/src/config/config.d.ts +1 -0
- package/dist/src/config/config.js +15 -3
- package/dist/src/config/config.js.map +1 -1
- package/dist/src/config/config.test.js +23 -15
- package/dist/src/config/config.test.js.map +1 -1
- package/dist/src/config/extension-manager.js +1 -2
- package/dist/src/config/extension-manager.js.map +1 -1
- package/dist/src/config/extension.test.js +27 -4
- package/dist/src/config/extension.test.js.map +1 -1
- package/dist/src/config/extensions/extensionEnablement.d.ts +1 -1
- package/dist/src/config/extensions/extensionEnablement.js +3 -2
- package/dist/src/config/extensions/extensionEnablement.js.map +1 -1
- package/dist/src/config/extensions/extensionEnablement.test.js +10 -10
- package/dist/src/config/extensions/extensionEnablement.test.js.map +1 -1
- package/dist/src/config/extensions/github_fetch.d.ts +1 -1
- package/dist/src/config/extensions/github_fetch.js +13 -1
- package/dist/src/config/extensions/github_fetch.js.map +1 -1
- package/dist/src/config/extensions/github_fetch.test.d.ts +6 -0
- package/dist/src/config/extensions/github_fetch.test.js +169 -0
- package/dist/src/config/extensions/github_fetch.test.js.map +1 -0
- package/dist/src/config/extensions/update.test.js +1 -0
- package/dist/src/config/extensions/update.test.js.map +1 -1
- package/dist/src/config/settings.test.js +2 -2
- package/dist/src/core/initializer.js +2 -1
- package/dist/src/core/initializer.js.map +1 -1
- package/dist/src/gemini.test.js +26 -2
- package/dist/src/gemini.test.js.map +1 -1
- package/dist/src/generated/git-commit.d.ts +2 -2
- package/dist/src/generated/git-commit.js +2 -2
- package/dist/src/nonInteractiveCli.js +16 -4
- package/dist/src/nonInteractiveCli.js.map +1 -1
- package/dist/src/nonInteractiveCli.test.js +67 -12
- package/dist/src/nonInteractiveCli.test.js.map +1 -1
- package/dist/src/ui/AppContainer.js +1 -1
- package/dist/src/ui/AppContainer.js.map +1 -1
- package/dist/src/ui/components/FolderTrustDialog.test.js +1 -0
- package/dist/src/ui/components/FolderTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/InputPrompt.test.js +442 -342
- package/dist/src/ui/components/InputPrompt.test.js.map +1 -1
- package/dist/src/ui/components/ModelDialog.test.js +1 -0
- package/dist/src/ui/components/ModelDialog.test.js.map +1 -1
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js +1 -0
- package/dist/src/ui/components/PermissionsModifyTrustDialog.test.js.map +1 -1
- package/dist/src/ui/components/SettingsDialog.test.js +2 -1
- package/dist/src/ui/components/SettingsDialog.test.js.map +1 -1
- package/dist/src/ui/components/ThemeDialog.test.js +1 -2
- package/dist/src/ui/components/ThemeDialog.test.js.map +1 -1
- package/dist/src/ui/components/shared/BaseSelectionList.test.js +1 -0
- package/dist/src/ui/components/shared/BaseSelectionList.test.js.map +1 -1
- package/dist/src/ui/components/shared/text-buffer.test.js +1 -0
- package/dist/src/ui/components/shared/text-buffer.test.js.map +1 -1
- package/dist/src/ui/components/views/ExtensionsList.d.ts +1 -1
- package/dist/src/ui/components/views/ExtensionsList.js +4 -1
- package/dist/src/ui/components/views/ExtensionsList.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.d.ts +3 -2
- package/dist/src/ui/contexts/KeypressContext.js +114 -64
- package/dist/src/ui/contexts/KeypressContext.js.map +1 -1
- package/dist/src/ui/contexts/KeypressContext.test.js +162 -479
- package/dist/src/ui/contexts/KeypressContext.test.js.map +1 -1
- package/dist/src/ui/contexts/SessionContext.test.js +1 -0
- package/dist/src/ui/contexts/SessionContext.test.js.map +1 -1
- package/dist/src/ui/hooks/shellCommandProcessor.test.js +18 -2
- package/dist/src/ui/hooks/shellCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/slashCommandProcessor.test.js +74 -80
- package/dist/src/ui/hooks/slashCommandProcessor.test.js.map +1 -1
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js +1 -0
- package/dist/src/ui/hooks/useAutoAcceptIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/useCommandCompletion.test.js +79 -78
- package/dist/src/ui/hooks/useCommandCompletion.test.js.map +1 -1
- package/dist/src/ui/hooks/useConsoleMessages.test.js +26 -9
- package/dist/src/ui/hooks/useConsoleMessages.test.js.map +1 -1
- package/dist/src/ui/hooks/useEditorSettings.test.js +40 -34
- package/dist/src/ui/hooks/useEditorSettings.test.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.d.ts +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.js +2 -1
- package/dist/src/ui/hooks/useExtensionUpdates.js.map +1 -1
- package/dist/src/ui/hooks/useExtensionUpdates.test.js +27 -10
- package/dist/src/ui/hooks/useExtensionUpdates.test.js.map +1 -1
- package/dist/src/ui/hooks/useFlickerDetector.test.js +1 -0
- package/dist/src/ui/hooks/useFlickerDetector.test.js.map +1 -1
- package/dist/src/ui/hooks/useFocus.test.js +25 -9
- package/dist/src/ui/hooks/useFocus.test.js.map +1 -1
- package/dist/src/ui/hooks/useFolderTrust.test.js +1 -0
- package/dist/src/ui/hooks/useFolderTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.js +49 -14
- package/dist/src/ui/hooks/useGeminiStream.js.map +1 -1
- package/dist/src/ui/hooks/useGeminiStream.test.js +114 -34
- package/dist/src/ui/hooks/useGeminiStream.test.js.map +1 -1
- package/dist/src/ui/hooks/useGitBranchName.test.js +29 -16
- package/dist/src/ui/hooks/useGitBranchName.test.js.map +1 -1
- package/dist/src/ui/hooks/useHistoryManager.test.js +1 -0
- package/dist/src/ui/hooks/useHistoryManager.test.js.map +1 -1
- package/dist/src/ui/hooks/useIdeTrustListener.test.js +24 -7
- package/dist/src/ui/hooks/useIdeTrustListener.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistory.test.js +1 -0
- package/dist/src/ui/hooks/useInputHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useInputHistoryStore.test.js +1 -0
- package/dist/src/ui/hooks/useInputHistoryStore.test.js.map +1 -1
- package/dist/src/ui/hooks/useKeypress.test.js +94 -113
- package/dist/src/ui/hooks/useKeypress.test.js.map +1 -1
- package/dist/src/ui/hooks/useLoadingIndicator.test.js +24 -6
- package/dist/src/ui/hooks/useLoadingIndicator.test.js.map +1 -1
- package/dist/src/ui/hooks/useMemoryMonitor.test.js +10 -5
- package/dist/src/ui/hooks/useMemoryMonitor.test.js.map +1 -1
- package/dist/src/ui/hooks/useMessageQueue.test.js +61 -45
- package/dist/src/ui/hooks/useMessageQueue.test.js.map +1 -1
- package/dist/src/ui/hooks/useModelCommand.test.js +18 -11
- package/dist/src/ui/hooks/useModelCommand.test.js.map +1 -1
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js +1 -0
- package/dist/src/ui/hooks/usePermissionsModifyTrust.test.js.map +1 -1
- package/dist/src/ui/hooks/usePhraseCycler.test.js +1 -0
- package/dist/src/ui/hooks/usePhraseCycler.test.js.map +1 -1
- package/dist/src/ui/hooks/usePrivacySettings.test.js +26 -10
- package/dist/src/ui/hooks/usePrivacySettings.test.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.js +13 -14
- package/dist/src/ui/hooks/useQuotaAndFallback.js.map +1 -1
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js +32 -39
- package/dist/src/ui/hooks/useQuotaAndFallback.test.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.d.ts +8 -1
- package/dist/src/ui/hooks/useReactToolScheduler.js +37 -26
- package/dist/src/ui/hooks/useReactToolScheduler.js.map +1 -1
- package/dist/src/ui/hooks/useReactToolScheduler.test.js +1 -0
- package/dist/src/ui/hooks/useReactToolScheduler.test.js.map +1 -1
- package/dist/src/ui/hooks/useSelectionList.test.js +193 -132
- package/dist/src/ui/hooks/useSelectionList.test.js.map +1 -1
- package/dist/src/ui/hooks/useShellHistory.test.js +1 -0
- package/dist/src/ui/hooks/useShellHistory.test.js.map +1 -1
- package/dist/src/ui/hooks/useTimer.test.js +43 -14
- package/dist/src/ui/hooks/useTimer.test.js.map +1 -1
- package/dist/src/ui/hooks/useToolScheduler.test.js +122 -39
- package/dist/src/ui/hooks/useToolScheduler.test.js.map +1 -1
- package/dist/src/ui/hooks/vim.test.js +251 -356
- package/dist/src/ui/hooks/vim.test.js.map +1 -1
- package/dist/src/ui/utils/textOutput.d.ts +25 -0
- package/dist/src/ui/utils/textOutput.js +49 -0
- package/dist/src/ui/utils/textOutput.js.map +1 -0
- package/dist/src/ui/utils/textOutput.test.d.ts +6 -0
- package/dist/src/ui/utils/textOutput.test.js +79 -0
- package/dist/src/ui/utils/textOutput.test.js.map +1 -0
- package/dist/src/ui/utils/updateCheck.d.ts +7 -1
- package/dist/src/ui/utils/updateCheck.js +27 -26
- package/dist/src/ui/utils/updateCheck.js.map +1 -1
- package/dist/src/ui/utils/updateCheck.test.js +19 -49
- package/dist/src/ui/utils/updateCheck.test.js.map +1 -1
- package/dist/src/utils/handleAutoUpdate.js +9 -3
- package/dist/src/utils/handleAutoUpdate.js.map +1 -1
- package/dist/src/zed-integration/zedIntegration.js +5 -10
- package/dist/src/zed-integration/zedIntegration.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
- package/dist/google-gemini-cli-0.12.0-nightly.20251022.0542de95.tgz +0 -0
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
1
2
|
/**
|
|
2
3
|
* @license
|
|
3
4
|
* Copyright 2025 Google LLC
|
|
4
5
|
* SPDX-License-Identifier: Apache-2.0
|
|
5
6
|
*/
|
|
6
7
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
7
|
-
import {
|
|
8
|
+
import { act } from 'react';
|
|
9
|
+
import { render } from 'ink-testing-library';
|
|
8
10
|
import { useVim } from './vim.js';
|
|
9
11
|
import { textBufferReducer } from '../components/shared/text-buffer.js';
|
|
10
12
|
// Mock the VimModeContext
|
|
@@ -154,7 +156,22 @@ describe('useVim hook', () => {
|
|
|
154
156
|
}),
|
|
155
157
|
};
|
|
156
158
|
};
|
|
157
|
-
const renderVimHook = (buffer) =>
|
|
159
|
+
const renderVimHook = (buffer) => {
|
|
160
|
+
let hookResult;
|
|
161
|
+
function TestComponent() {
|
|
162
|
+
hookResult = useVim((buffer || mockBuffer), mockHandleFinalSubmit);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const { rerender } = render(_jsx(TestComponent, {}));
|
|
166
|
+
return {
|
|
167
|
+
result: {
|
|
168
|
+
get current() {
|
|
169
|
+
return hookResult;
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
rerender: () => rerender(_jsx(TestComponent, {})),
|
|
173
|
+
};
|
|
174
|
+
};
|
|
158
175
|
const exitInsertMode = (result) => {
|
|
159
176
|
act(() => {
|
|
160
177
|
result.current.handleInput(TEST_SEQUENCES.ESCAPE);
|
|
@@ -1006,23 +1023,32 @@ describe('useVim hook', () => {
|
|
|
1006
1023
|
});
|
|
1007
1024
|
});
|
|
1008
1025
|
describe('Shell command pass-through', () => {
|
|
1009
|
-
it('should pass through ctrl+r in INSERT mode', () => {
|
|
1026
|
+
it('should pass through ctrl+r in INSERT mode', async () => {
|
|
1010
1027
|
mockVimContext.vimMode = 'INSERT';
|
|
1011
1028
|
const { result } = renderVimHook();
|
|
1029
|
+
await vi.waitFor(() => {
|
|
1030
|
+
expect(result.current.mode).toBe('INSERT');
|
|
1031
|
+
});
|
|
1012
1032
|
const handled = result.current.handleInput(createKey({ name: 'r', ctrl: true }));
|
|
1013
1033
|
expect(handled).toBe(false);
|
|
1014
1034
|
});
|
|
1015
|
-
it('should pass through ! in INSERT mode when buffer is empty', () => {
|
|
1035
|
+
it('should pass through ! in INSERT mode when buffer is empty', async () => {
|
|
1016
1036
|
mockVimContext.vimMode = 'INSERT';
|
|
1017
1037
|
const emptyBuffer = createMockBuffer('');
|
|
1018
1038
|
const { result } = renderVimHook(emptyBuffer);
|
|
1039
|
+
await vi.waitFor(() => {
|
|
1040
|
+
expect(result.current.mode).toBe('INSERT');
|
|
1041
|
+
});
|
|
1019
1042
|
const handled = result.current.handleInput(createKey({ sequence: '!' }));
|
|
1020
1043
|
expect(handled).toBe(false);
|
|
1021
1044
|
});
|
|
1022
|
-
it('should handle ! as input in INSERT mode when buffer is not empty', () => {
|
|
1045
|
+
it('should handle ! as input in INSERT mode when buffer is not empty', async () => {
|
|
1023
1046
|
mockVimContext.vimMode = 'INSERT';
|
|
1024
1047
|
const nonEmptyBuffer = createMockBuffer('not empty');
|
|
1025
1048
|
const { result } = renderVimHook(nonEmptyBuffer);
|
|
1049
|
+
await vi.waitFor(() => {
|
|
1050
|
+
expect(result.current.mode).toBe('INSERT');
|
|
1051
|
+
});
|
|
1026
1052
|
const key = createKey({ sequence: '!', name: '!' });
|
|
1027
1053
|
act(() => {
|
|
1028
1054
|
result.current.handleInput(key);
|
|
@@ -1032,357 +1058,226 @@ describe('useVim hook', () => {
|
|
|
1032
1058
|
});
|
|
1033
1059
|
// Line operations (dd, cc) are tested in text-buffer.test.ts
|
|
1034
1060
|
describe('Reducer-based integration tests', () => {
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
clipboard: null,
|
|
1256
|
-
selectionAnchor: null,
|
|
1257
|
-
});
|
|
1258
|
-
const result = textBufferReducer(initialState, {
|
|
1259
|
-
type: 'vim_delete_line',
|
|
1260
|
-
payload: { count: 1 },
|
|
1261
|
-
});
|
|
1262
|
-
expect(result.lines).toEqual(['line1', 'line3']);
|
|
1263
|
-
expect(result.cursorRow).toBe(1);
|
|
1264
|
-
expect(result.cursorCol).toBe(0);
|
|
1265
|
-
});
|
|
1266
|
-
it('should delete multiple lines with count', () => {
|
|
1267
|
-
const initialState = createMockTextBufferState({
|
|
1268
|
-
lines: ['line1', 'line2', 'line3', 'line4'],
|
|
1269
|
-
cursorRow: 1,
|
|
1270
|
-
cursorCol: 2,
|
|
1271
|
-
preferredCol: null,
|
|
1272
|
-
undoStack: [],
|
|
1273
|
-
redoStack: [],
|
|
1274
|
-
clipboard: null,
|
|
1275
|
-
selectionAnchor: null,
|
|
1276
|
-
});
|
|
1277
|
-
const result = textBufferReducer(initialState, {
|
|
1278
|
-
type: 'vim_delete_line',
|
|
1279
|
-
payload: { count: 2 },
|
|
1280
|
-
});
|
|
1281
|
-
// Should delete lines 1 and 2
|
|
1282
|
-
expect(result.lines).toEqual(['line1', 'line4']);
|
|
1283
|
-
expect(result.cursorRow).toBe(1);
|
|
1284
|
-
expect(result.cursorCol).toBe(0);
|
|
1285
|
-
});
|
|
1286
|
-
it('should handle deleting last line', () => {
|
|
1287
|
-
const initialState = createMockTextBufferState({
|
|
1288
|
-
lines: ['only line'],
|
|
1289
|
-
cursorRow: 0,
|
|
1290
|
-
cursorCol: 3,
|
|
1291
|
-
preferredCol: null,
|
|
1292
|
-
undoStack: [],
|
|
1293
|
-
redoStack: [],
|
|
1294
|
-
clipboard: null,
|
|
1295
|
-
selectionAnchor: null,
|
|
1296
|
-
});
|
|
1297
|
-
const result = textBufferReducer(initialState, {
|
|
1298
|
-
type: 'vim_delete_line',
|
|
1299
|
-
payload: { count: 1 },
|
|
1300
|
-
});
|
|
1301
|
-
// Should leave an empty line when deleting the only line
|
|
1302
|
-
expect(result.lines).toEqual(['']);
|
|
1303
|
-
expect(result.cursorRow).toBe(0);
|
|
1304
|
-
expect(result.cursorCol).toBe(0);
|
|
1305
|
-
});
|
|
1306
|
-
});
|
|
1307
|
-
describe('D (delete to end of line)', () => {
|
|
1308
|
-
it('should delete from cursor to end of line', () => {
|
|
1309
|
-
const initialState = createMockTextBufferState({
|
|
1310
|
-
lines: ['hello world test'],
|
|
1311
|
-
cursorRow: 0,
|
|
1312
|
-
cursorCol: 6, // cursor on 'w' in "world"
|
|
1313
|
-
preferredCol: null,
|
|
1314
|
-
undoStack: [],
|
|
1315
|
-
redoStack: [],
|
|
1316
|
-
clipboard: null,
|
|
1317
|
-
selectionAnchor: null,
|
|
1318
|
-
});
|
|
1319
|
-
const result = textBufferReducer(initialState, {
|
|
1320
|
-
type: 'vim_delete_to_end_of_line',
|
|
1321
|
-
});
|
|
1322
|
-
// Should delete "world test", leaving "hello "
|
|
1323
|
-
expect(result.lines).toEqual(['hello ']);
|
|
1324
|
-
expect(result.cursorRow).toBe(0);
|
|
1325
|
-
expect(result.cursorCol).toBe(6);
|
|
1326
|
-
});
|
|
1327
|
-
it('should handle D at end of line', () => {
|
|
1328
|
-
const initialState = createMockTextBufferState({
|
|
1329
|
-
lines: ['hello world'],
|
|
1330
|
-
cursorRow: 0,
|
|
1331
|
-
cursorCol: 11, // cursor at end
|
|
1332
|
-
preferredCol: null,
|
|
1333
|
-
undoStack: [],
|
|
1334
|
-
redoStack: [],
|
|
1335
|
-
clipboard: null,
|
|
1336
|
-
selectionAnchor: null,
|
|
1337
|
-
});
|
|
1338
|
-
const result = textBufferReducer(initialState, {
|
|
1339
|
-
type: 'vim_delete_to_end_of_line',
|
|
1340
|
-
});
|
|
1341
|
-
// Should not change anything when at end of line
|
|
1342
|
-
expect(result.lines).toEqual(['hello world']);
|
|
1343
|
-
expect(result.cursorRow).toBe(0);
|
|
1344
|
-
expect(result.cursorCol).toBe(11);
|
|
1345
|
-
});
|
|
1346
|
-
});
|
|
1347
|
-
describe('C (change to end of line)', () => {
|
|
1348
|
-
it('should change from cursor to end of line', () => {
|
|
1349
|
-
const initialState = createMockTextBufferState({
|
|
1350
|
-
lines: ['hello world test'],
|
|
1351
|
-
cursorRow: 0,
|
|
1352
|
-
cursorCol: 6, // cursor on 'w' in "world"
|
|
1353
|
-
preferredCol: null,
|
|
1354
|
-
undoStack: [],
|
|
1355
|
-
redoStack: [],
|
|
1356
|
-
clipboard: null,
|
|
1357
|
-
selectionAnchor: null,
|
|
1358
|
-
});
|
|
1359
|
-
const result = textBufferReducer(initialState, {
|
|
1360
|
-
type: 'vim_change_to_end_of_line',
|
|
1361
|
-
});
|
|
1362
|
-
// Should delete "world test", leaving "hello "
|
|
1363
|
-
expect(result.lines).toEqual(['hello ']);
|
|
1364
|
-
expect(result.cursorRow).toBe(0);
|
|
1365
|
-
expect(result.cursorCol).toBe(6);
|
|
1366
|
-
});
|
|
1367
|
-
it('should handle C at beginning of line', () => {
|
|
1368
|
-
const initialState = createMockTextBufferState({
|
|
1369
|
-
lines: ['hello world'],
|
|
1370
|
-
cursorRow: 0,
|
|
1371
|
-
cursorCol: 0,
|
|
1372
|
-
preferredCol: null,
|
|
1373
|
-
undoStack: [],
|
|
1374
|
-
redoStack: [],
|
|
1375
|
-
clipboard: null,
|
|
1376
|
-
selectionAnchor: null,
|
|
1377
|
-
});
|
|
1378
|
-
const result = textBufferReducer(initialState, {
|
|
1379
|
-
type: 'vim_change_to_end_of_line',
|
|
1380
|
-
});
|
|
1381
|
-
// Should delete entire line content
|
|
1382
|
-
expect(result.lines).toEqual(['']);
|
|
1383
|
-
expect(result.cursorRow).toBe(0);
|
|
1384
|
-
expect(result.cursorCol).toBe(0);
|
|
1385
|
-
});
|
|
1061
|
+
const testCases = [
|
|
1062
|
+
{
|
|
1063
|
+
command: 'de',
|
|
1064
|
+
desc: 'delete from cursor to end of current word',
|
|
1065
|
+
lines: ['hello world test'],
|
|
1066
|
+
cursorRow: 0,
|
|
1067
|
+
cursorCol: 1,
|
|
1068
|
+
actionType: 'vim_delete_word_end',
|
|
1069
|
+
count: 1,
|
|
1070
|
+
expectedLines: ['h world test'],
|
|
1071
|
+
expectedCursorRow: 0,
|
|
1072
|
+
expectedCursorCol: 1,
|
|
1073
|
+
},
|
|
1074
|
+
{
|
|
1075
|
+
command: 'de',
|
|
1076
|
+
desc: 'delete multiple word ends with count',
|
|
1077
|
+
lines: ['hello world test more'],
|
|
1078
|
+
cursorRow: 0,
|
|
1079
|
+
cursorCol: 1,
|
|
1080
|
+
actionType: 'vim_delete_word_end',
|
|
1081
|
+
count: 2,
|
|
1082
|
+
expectedLines: ['h test more'],
|
|
1083
|
+
expectedCursorRow: 0,
|
|
1084
|
+
expectedCursorCol: 1,
|
|
1085
|
+
},
|
|
1086
|
+
{
|
|
1087
|
+
command: 'db',
|
|
1088
|
+
desc: 'delete from cursor to start of previous word',
|
|
1089
|
+
lines: ['hello world test'],
|
|
1090
|
+
cursorRow: 0,
|
|
1091
|
+
cursorCol: 11,
|
|
1092
|
+
actionType: 'vim_delete_word_backward',
|
|
1093
|
+
count: 1,
|
|
1094
|
+
expectedLines: ['hello test'],
|
|
1095
|
+
expectedCursorRow: 0,
|
|
1096
|
+
expectedCursorCol: 6,
|
|
1097
|
+
},
|
|
1098
|
+
{
|
|
1099
|
+
command: 'db',
|
|
1100
|
+
desc: 'delete multiple words backward with count',
|
|
1101
|
+
lines: ['hello world test more'],
|
|
1102
|
+
cursorRow: 0,
|
|
1103
|
+
cursorCol: 17,
|
|
1104
|
+
actionType: 'vim_delete_word_backward',
|
|
1105
|
+
count: 2,
|
|
1106
|
+
expectedLines: ['hello more'],
|
|
1107
|
+
expectedCursorRow: 0,
|
|
1108
|
+
expectedCursorCol: 6,
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
command: 'cw',
|
|
1112
|
+
desc: 'delete from cursor to start of next word',
|
|
1113
|
+
lines: ['hello world test'],
|
|
1114
|
+
cursorRow: 0,
|
|
1115
|
+
cursorCol: 0,
|
|
1116
|
+
actionType: 'vim_change_word_forward',
|
|
1117
|
+
count: 1,
|
|
1118
|
+
expectedLines: ['world test'],
|
|
1119
|
+
expectedCursorRow: 0,
|
|
1120
|
+
expectedCursorCol: 0,
|
|
1121
|
+
},
|
|
1122
|
+
{
|
|
1123
|
+
command: 'cw',
|
|
1124
|
+
desc: 'change multiple words with count',
|
|
1125
|
+
lines: ['hello world test more'],
|
|
1126
|
+
cursorRow: 0,
|
|
1127
|
+
cursorCol: 0,
|
|
1128
|
+
actionType: 'vim_change_word_forward',
|
|
1129
|
+
count: 2,
|
|
1130
|
+
expectedLines: ['test more'],
|
|
1131
|
+
expectedCursorRow: 0,
|
|
1132
|
+
expectedCursorCol: 0,
|
|
1133
|
+
},
|
|
1134
|
+
{
|
|
1135
|
+
command: 'ce',
|
|
1136
|
+
desc: 'change from cursor to end of current word',
|
|
1137
|
+
lines: ['hello world test'],
|
|
1138
|
+
cursorRow: 0,
|
|
1139
|
+
cursorCol: 1,
|
|
1140
|
+
actionType: 'vim_change_word_end',
|
|
1141
|
+
count: 1,
|
|
1142
|
+
expectedLines: ['h world test'],
|
|
1143
|
+
expectedCursorRow: 0,
|
|
1144
|
+
expectedCursorCol: 1,
|
|
1145
|
+
},
|
|
1146
|
+
{
|
|
1147
|
+
command: 'ce',
|
|
1148
|
+
desc: 'change multiple word ends with count',
|
|
1149
|
+
lines: ['hello world test'],
|
|
1150
|
+
cursorRow: 0,
|
|
1151
|
+
cursorCol: 1,
|
|
1152
|
+
actionType: 'vim_change_word_end',
|
|
1153
|
+
count: 2,
|
|
1154
|
+
expectedLines: ['h test'],
|
|
1155
|
+
expectedCursorRow: 0,
|
|
1156
|
+
expectedCursorCol: 1,
|
|
1157
|
+
},
|
|
1158
|
+
{
|
|
1159
|
+
command: 'cb',
|
|
1160
|
+
desc: 'change from cursor to start of previous word',
|
|
1161
|
+
lines: ['hello world test'],
|
|
1162
|
+
cursorRow: 0,
|
|
1163
|
+
cursorCol: 11,
|
|
1164
|
+
actionType: 'vim_change_word_backward',
|
|
1165
|
+
count: 1,
|
|
1166
|
+
expectedLines: ['hello test'],
|
|
1167
|
+
expectedCursorRow: 0,
|
|
1168
|
+
expectedCursorCol: 6,
|
|
1169
|
+
},
|
|
1170
|
+
{
|
|
1171
|
+
command: 'cc',
|
|
1172
|
+
desc: 'clear the line and place cursor at the start',
|
|
1173
|
+
lines: [' hello world'],
|
|
1174
|
+
cursorRow: 0,
|
|
1175
|
+
cursorCol: 5,
|
|
1176
|
+
actionType: 'vim_change_line',
|
|
1177
|
+
count: 1,
|
|
1178
|
+
expectedLines: [''],
|
|
1179
|
+
expectedCursorRow: 0,
|
|
1180
|
+
expectedCursorCol: 0,
|
|
1181
|
+
},
|
|
1182
|
+
{
|
|
1183
|
+
command: 'dd',
|
|
1184
|
+
desc: 'delete the current line',
|
|
1185
|
+
lines: ['line1', 'line2', 'line3'],
|
|
1186
|
+
cursorRow: 1,
|
|
1187
|
+
cursorCol: 2,
|
|
1188
|
+
actionType: 'vim_delete_line',
|
|
1189
|
+
count: 1,
|
|
1190
|
+
expectedLines: ['line1', 'line3'],
|
|
1191
|
+
expectedCursorRow: 1,
|
|
1192
|
+
expectedCursorCol: 0,
|
|
1193
|
+
},
|
|
1194
|
+
{
|
|
1195
|
+
command: 'dd',
|
|
1196
|
+
desc: 'delete multiple lines with count',
|
|
1197
|
+
lines: ['line1', 'line2', 'line3', 'line4'],
|
|
1198
|
+
cursorRow: 1,
|
|
1199
|
+
cursorCol: 2,
|
|
1200
|
+
actionType: 'vim_delete_line',
|
|
1201
|
+
count: 2,
|
|
1202
|
+
expectedLines: ['line1', 'line4'],
|
|
1203
|
+
expectedCursorRow: 1,
|
|
1204
|
+
expectedCursorCol: 0,
|
|
1205
|
+
},
|
|
1206
|
+
{
|
|
1207
|
+
command: 'dd',
|
|
1208
|
+
desc: 'handle deleting last line',
|
|
1209
|
+
lines: ['only line'],
|
|
1210
|
+
cursorRow: 0,
|
|
1211
|
+
cursorCol: 3,
|
|
1212
|
+
actionType: 'vim_delete_line',
|
|
1213
|
+
count: 1,
|
|
1214
|
+
expectedLines: [''],
|
|
1215
|
+
expectedCursorRow: 0,
|
|
1216
|
+
expectedCursorCol: 0,
|
|
1217
|
+
},
|
|
1218
|
+
{
|
|
1219
|
+
command: 'D',
|
|
1220
|
+
desc: 'delete from cursor to end of line',
|
|
1221
|
+
lines: ['hello world test'],
|
|
1222
|
+
cursorRow: 0,
|
|
1223
|
+
cursorCol: 6,
|
|
1224
|
+
actionType: 'vim_delete_to_end_of_line',
|
|
1225
|
+
expectedLines: ['hello '],
|
|
1226
|
+
expectedCursorRow: 0,
|
|
1227
|
+
expectedCursorCol: 6,
|
|
1228
|
+
},
|
|
1229
|
+
{
|
|
1230
|
+
command: 'D',
|
|
1231
|
+
desc: 'handle D at end of line',
|
|
1232
|
+
lines: ['hello world'],
|
|
1233
|
+
cursorRow: 0,
|
|
1234
|
+
cursorCol: 11,
|
|
1235
|
+
actionType: 'vim_delete_to_end_of_line',
|
|
1236
|
+
expectedLines: ['hello world'],
|
|
1237
|
+
expectedCursorRow: 0,
|
|
1238
|
+
expectedCursorCol: 11,
|
|
1239
|
+
},
|
|
1240
|
+
{
|
|
1241
|
+
command: 'C',
|
|
1242
|
+
desc: 'change from cursor to end of line',
|
|
1243
|
+
lines: ['hello world test'],
|
|
1244
|
+
cursorRow: 0,
|
|
1245
|
+
cursorCol: 6,
|
|
1246
|
+
actionType: 'vim_change_to_end_of_line',
|
|
1247
|
+
expectedLines: ['hello '],
|
|
1248
|
+
expectedCursorRow: 0,
|
|
1249
|
+
expectedCursorCol: 6,
|
|
1250
|
+
},
|
|
1251
|
+
{
|
|
1252
|
+
command: 'C',
|
|
1253
|
+
desc: 'handle C at beginning of line',
|
|
1254
|
+
lines: ['hello world'],
|
|
1255
|
+
cursorRow: 0,
|
|
1256
|
+
cursorCol: 0,
|
|
1257
|
+
actionType: 'vim_change_to_end_of_line',
|
|
1258
|
+
expectedLines: [''],
|
|
1259
|
+
expectedCursorRow: 0,
|
|
1260
|
+
expectedCursorCol: 0,
|
|
1261
|
+
},
|
|
1262
|
+
];
|
|
1263
|
+
it.each(testCases)('$command: should $desc', ({ lines, cursorRow, cursorCol, actionType, count, expectedLines, expectedCursorRow, expectedCursorCol, }) => {
|
|
1264
|
+
const initialState = createMockTextBufferState({
|
|
1265
|
+
lines,
|
|
1266
|
+
cursorRow,
|
|
1267
|
+
cursorCol,
|
|
1268
|
+
preferredCol: null,
|
|
1269
|
+
undoStack: [],
|
|
1270
|
+
redoStack: [],
|
|
1271
|
+
clipboard: null,
|
|
1272
|
+
selectionAnchor: null,
|
|
1273
|
+
});
|
|
1274
|
+
const action = (count
|
|
1275
|
+
? { type: actionType, payload: { count } }
|
|
1276
|
+
: { type: actionType });
|
|
1277
|
+
const result = textBufferReducer(initialState, action);
|
|
1278
|
+
expect(result.lines).toEqual(expectedLines);
|
|
1279
|
+
expect(result.cursorRow).toBe(expectedCursorRow);
|
|
1280
|
+
expect(result.cursorCol).toBe(expectedCursorCol);
|
|
1386
1281
|
});
|
|
1387
1282
|
});
|
|
1388
1283
|
});
|