-
Notifications
You must be signed in to change notification settings - Fork 70
Expand file tree
/
Copy pathroo_code_refactor_addLogging
More file actions
384 lines (363 loc) · 15.1 KB
/
roo_code_refactor_addLogging
File metadata and controls
384 lines (363 loc) · 15.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
diff --git a/src/vs/editor/browser/coreCommands.ts b/src/vs/editor/browser/coreCommands.ts
index 9331eea48ff..6dde1785667 100644
--- a/src/vs/editor/browser/coreCommands.ts
+++ b/src/vs/editor/browser/coreCommands.ts
@@ -2141,12 +2141,17 @@ class EditorHandlerCommand extends Command {
}
public runCommand(accessor: ServicesAccessor, args: unknown): void {
- const editor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
- if (!editor) {
- return;
- }
+ console.log('Entering EditorHandlerCommand.runCommand');
+ try {
+ const editor = accessor.get(ICodeEditorService).getFocusedCodeEditor();
+ if (!editor) {
+ return;
+ }
- editor.trigger('keyboard', this._handlerId, args);
+ editor.trigger('keyboard', this._handlerId, args);
+ } finally {
+ console.log('Exiting EditorHandlerCommand.runCommand');
+ }
}
}
diff --git a/src/vs/editor/browser/editorExtensions.ts b/src/vs/editor/browser/editorExtensions.ts
index d5961dd4f1e..fd1f6df618c 100644
--- a/src/vs/editor/browser/editorExtensions.ts
+++ b/src/vs/editor/browser/editorExtensions.ts
@@ -223,27 +223,32 @@ export class MultiCommand extends Command {
}
public runCommand(accessor: ServicesAccessor, args: unknown): void | Promise<void> {
- const logService = accessor.get(ILogService);
- const contextKeyService = accessor.get(IContextKeyService);
- logService.trace(`Executing Command '${this.id}' which has ${this._implementations.length} bound.`);
- for (const impl of this._implementations) {
- if (impl.when) {
- const context = contextKeyService.getContext(getActiveElement());
- const value = impl.when.evaluate(context);
- if (!value) {
- continue;
+ console.log('Entering MultiCommand.runCommand');
+ try {
+ const logService = accessor.get(ILogService);
+ const contextKeyService = accessor.get(IContextKeyService);
+ logService.trace(`Executing Command '${this.id}' which has ${this._implementations.length} bound.`);
+ for (const impl of this._implementations) {
+ if (impl.when) {
+ const context = contextKeyService.getContext(getActiveElement());
+ const value = impl.when.evaluate(context);
+ if (!value) {
+ continue;
+ }
}
- }
- const result = impl.implementation(accessor, args);
- if (result) {
- logService.trace(`Command '${this.id}' was handled by '${impl.name}'.`);
- if (typeof result === 'boolean') {
- return;
+ const result = impl.implementation(accessor, args);
+ if (result) {
+ logService.trace(`Command '${this.id}' was handled by '${impl.name}'.`);
+ if (typeof result === 'boolean') {
+ return;
+ }
+ return result;
}
- return result;
}
+ logService.trace(`The Command '${this.id}' was not handled by any implementation.`);
+ } finally {
+ console.log('Exiting MultiCommand.runCommand');
}
- logService.trace(`The Command '${this.id}' was not handled by any implementation.`);
}
}
@@ -263,7 +268,12 @@ export class ProxyCommand extends Command {
}
public runCommand(accessor: ServicesAccessor, args: unknown): void | Promise<void> {
- return this.command.runCommand(accessor, args);
+ console.log('Entering ProxyCommand.runCommand');
+ try {
+ return this.command.runCommand(accessor, args);
+ } finally {
+ console.log('Exiting ProxyCommand.runCommand');
+ }
}
}
@@ -326,7 +336,12 @@ export abstract class EditorCommand extends Command {
}
public runCommand(accessor: ServicesAccessor, args: unknown): void | Promise<void> {
- return EditorCommand.runEditorCommand(accessor, args, this.precondition, (accessor, editor, args) => this.runEditorCommand(accessor, editor, args));
+ console.log('Entering EditorCommand.runCommand');
+ try {
+ return EditorCommand.runEditorCommand(accessor, args, this.precondition, (accessor, editor, args) => this.runEditorCommand(accessor, editor, args));
+ } finally {
+ console.log('Exiting EditorCommand.runCommand');
+ }
}
public abstract runEditorCommand(accessor: ServicesAccessor, editor: ICodeEditor, args: unknown): void | Promise<void>;
diff --git a/src/vs/editor/contrib/linkedEditing/browser/linkedEditing.ts b/src/vs/editor/contrib/linkedEditing/browser/linkedEditing.ts
index 09f9257f2d7..7f6e6b97025 100644
--- a/src/vs/editor/contrib/linkedEditing/browser/linkedEditing.ts
+++ b/src/vs/editor/contrib/linkedEditing/browser/linkedEditing.ts
@@ -410,23 +410,28 @@ export class LinkedEditingAction extends EditorAction {
}
override runCommand(accessor: ServicesAccessor, args: [URI, IPosition]): void | Promise<void> {
- const editorService = accessor.get(ICodeEditorService);
- const [uri, pos] = Array.isArray(args) && args || [undefined, undefined];
+ console.log('Entering LinkedEditingAction.runCommand');
+ try {
+ const editorService = accessor.get(ICodeEditorService);
+ const [uri, pos] = Array.isArray(args) && args || [undefined, undefined];
- if (URI.isUri(uri) && Position.isIPosition(pos)) {
- return editorService.openCodeEditor({ resource: uri }, editorService.getActiveCodeEditor()).then(editor => {
- if (!editor) {
- return;
- }
- editor.setPosition(pos);
- editor.invokeWithinContext(accessor => {
- this.reportTelemetry(accessor, editor);
- return this.run(accessor, editor);
- });
- }, onUnexpectedError);
- }
+ if (URI.isUri(uri) && Position.isIPosition(pos)) {
+ return editorService.openCodeEditor({ resource: uri }, editorService.getActiveCodeEditor()).then(editor => {
+ if (!editor) {
+ return;
+ }
+ editor.setPosition(pos);
+ editor.invokeWithinContext(accessor => {
+ this.reportTelemetry(accessor, editor);
+ return this.run(accessor, editor);
+ });
+ }, onUnexpectedError);
+ }
- return super.runCommand(accessor, args);
+ return super.runCommand(accessor, args);
+ } finally {
+ console.log('Exiting LinkedEditingAction.runCommand');
+ }
}
run(_accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
diff --git a/src/vs/editor/contrib/rename/browser/rename.ts b/src/vs/editor/contrib/rename/browser/rename.ts
index cf675f54cf4..fe7d2397b14 100644
--- a/src/vs/editor/contrib/rename/browser/rename.ts
+++ b/src/vs/editor/contrib/rename/browser/rename.ts
@@ -379,23 +379,28 @@ export class RenameAction extends EditorAction {
}
override runCommand(accessor: ServicesAccessor, args: [URI, IPosition]): void | Promise<void> {
- const editorService = accessor.get(ICodeEditorService);
- const [uri, pos] = Array.isArray(args) && args || [undefined, undefined];
+ console.log('Entering RenameAction.runCommand');
+ try {
+ const editorService = accessor.get(ICodeEditorService);
+ const [uri, pos] = Array.isArray(args) && args || [undefined, undefined];
+
+ if (URI.isUri(uri) && Position.isIPosition(pos)) {
+ return editorService.openCodeEditor({ resource: uri }, editorService.getActiveCodeEditor()).then(editor => {
+ if (!editor) {
+ return;
+ }
+ editor.setPosition(pos);
+ editor.invokeWithinContext(accessor => {
+ this.reportTelemetry(accessor, editor);
+ return this.run(accessor, editor);
+ });
+ }, onUnexpectedError);
+ }
- if (URI.isUri(uri) && Position.isIPosition(pos)) {
- return editorService.openCodeEditor({ resource: uri }, editorService.getActiveCodeEditor()).then(editor => {
- if (!editor) {
- return;
- }
- editor.setPosition(pos);
- editor.invokeWithinContext(accessor => {
- this.reportTelemetry(accessor, editor);
- return this.run(accessor, editor);
- });
- }, onUnexpectedError);
+ return super.runCommand(accessor, args);
+ } finally {
+ console.log('Exiting RenameAction.runCommand');
}
-
- return super.runCommand(accessor, args);
}
run(accessor: ServicesAccessor, editor: ICodeEditor): Promise<void> {
diff --git a/src/vs/editor/test/browser/testCodeEditor.ts b/src/vs/editor/test/browser/testCodeEditor.ts
index adede234180..9831b882354 100644
--- a/src/vs/editor/test/browser/testCodeEditor.ts
+++ b/src/vs/editor/test/browser/testCodeEditor.ts
@@ -114,9 +114,14 @@ export class TestCodeEditor extends CodeEditorWidget implements ICodeEditor {
this._register(disposable);
}
public runCommand(command: EditorCommand, args?: any): void | Promise<void> {
- return this._instantiationService.invokeFunction((accessor) => {
- return command.runEditorCommand(accessor, this, args);
- });
+ console.log('Entering TestCodeEditor.runCommand');
+ try {
+ return this._instantiationService.invokeFunction((accessor) => {
+ return command.runEditorCommand(accessor, this, args);
+ });
+ } finally {
+ console.log('Exiting TestCodeEditor.runCommand');
+ }
}
public runAction(action: ITestEditorAction, args?: any): void | Promise<void> {
return this._instantiationService.invokeFunction((accessor) => {
diff --git a/src/vs/workbench/contrib/commands/common/commands.contribution.ts b/src/vs/workbench/contrib/commands/common/commands.contribution.ts
index 3fd6b59a3b0..98f6f4f0a43 100644
--- a/src/vs/workbench/contrib/commands/common/commands.contribution.ts
+++ b/src/vs/workbench/contrib/commands/common/commands.contribution.ts
@@ -133,23 +133,28 @@ class RunCommands extends Action2 {
}
private _runCommand(commandService: ICommandService, cmd: RunnableCommand) {
- let commandID: string, commandArgs;
+ console.log('Entering RunCommands._runCommand');
+ try {
+ let commandID: string, commandArgs;
- if (typeof cmd === 'string') {
- commandID = cmd;
- } else {
- commandID = cmd.command;
- commandArgs = cmd.args;
- }
+ if (typeof cmd === 'string') {
+ commandID = cmd;
+ } else {
+ commandID = cmd.command;
+ commandArgs = cmd.args;
+ }
- if (commandArgs === undefined) {
- return commandService.executeCommand(commandID);
- } else {
- if (Array.isArray(commandArgs)) {
- return commandService.executeCommand(commandID, ...commandArgs);
+ if (commandArgs === undefined) {
+ return commandService.executeCommand(commandID);
} else {
- return commandService.executeCommand(commandID, commandArgs);
+ if (Array.isArray(commandArgs)) {
+ return commandService.executeCommand(commandID, ...commandArgs);
+ } else {
+ return commandService.executeCommand(commandID, commandArgs);
+ }
}
+ } finally {
+ console.log('Exiting RunCommands._runCommand');
}
}
}
diff --git a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
index 75894ea61eb..24b3a89f75c 100644
--- a/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
+++ b/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts
@@ -975,54 +975,59 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
}
async runCommand(commandLine: string, shouldExecute: boolean, commandId?: string, forceBracketedPasteMode?: boolean): Promise<void> {
- let commandDetection = this.capabilities.get(TerminalCapability.CommandDetection);
- const siInjectionEnabled = this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled) === true;
- const timeoutMs = getShellIntegrationTimeout(
- this._configurationService,
- siInjectionEnabled,
- this.hasRemoteAuthority,
- this._processManager.processReadyTimestamp
- );
-
- if (!commandDetection || commandDetection.promptInputModel.state !== PromptInputState.Input) {
- const store = new DisposableStore();
-
- await Promise.race([
- new Promise<void>(r => {
- store.add(this.capabilities.onDidAddCommandDetectionCapability(e => {
- commandDetection = e;
- if (commandDetection.promptInputModel.state === PromptInputState.Input) {
- r();
- } else {
- store.add(commandDetection.promptInputModel.onDidStartInput(() => {
+ console.log('Entering TerminalInstance.runCommand');
+ try {
+ let commandDetection = this.capabilities.get(TerminalCapability.CommandDetection);
+ const siInjectionEnabled = this._configurationService.getValue(TerminalSettingId.ShellIntegrationEnabled) === true;
+ const timeoutMs = getShellIntegrationTimeout(
+ this._configurationService,
+ siInjectionEnabled,
+ this.hasRemoteAuthority,
+ this._processManager.processReadyTimestamp
+ );
+
+ if (!commandDetection || commandDetection.promptInputModel.state !== PromptInputState.Input) {
+ const store = new DisposableStore();
+
+ await Promise.race([
+ new Promise<void>(r => {
+ store.add(this.capabilities.onDidAddCommandDetectionCapability(e => {
+ commandDetection = e;
+ if (commandDetection.promptInputModel.state === PromptInputState.Input) {
r();
- }));
- }
- }));
- }),
- timeout(timeoutMs)
- ]);
- store.dispose();
- }
-
- // If a command ID was provided and we have command detection, set it as the next command ID
- // so it will be used when the shell sends the command start sequence
- if (commandId && commandDetection) {
- this.xterm?.shellIntegration.setNextCommandId(commandLine, commandId);
- await this._processManager.setNextCommandId(commandLine, commandId);
- }
-
- // Determine whether to send ETX (ctrl+c) before running the command. Only do this when the
- // command will be executed immediately or when command detection shows the prompt contains text.
- if (shouldExecute && (!commandDetection || commandDetection.promptInputModel.value.length > 0)) {
- await this.sendText('\x03', false);
- // Wait a little before running the command to avoid the sequences being echoed while the ^C
- // is being evaluated
- await timeout(100);
- }
- // By default, use bracketed paste mode only when not running the command; callers can override
- // this by explicitly enabling it via the bracketedPasteMode argument.
- await this.sendText(commandLine, shouldExecute, !shouldExecute || forceBracketedPasteMode);
+ } else {
+ store.add(commandDetection.promptInputModel.onDidStartInput(() => {
+ r();
+ }));
+ }
+ }));
+ }),
+ timeout(timeoutMs)
+ ]);
+ store.dispose();
+ }
+
+ // If a command ID was provided and we have command detection, set it as the next command ID
+ // so it will be used when the shell sends the command start sequence
+ if (commandId && commandDetection) {
+ this.xterm?.shellIntegration.setNextCommandId(commandLine, commandId);
+ await this._processManager.setNextCommandId(commandLine, commandId);
+ }
+
+ // Determine whether to send ETX (ctrl+c) before running the command. Only do this when the
+ // command will be executed immediately or when command detection shows the prompt contains text.
+ if (shouldExecute && (!commandDetection || commandDetection.promptInputModel.value.length > 0)) {
+ await this.sendText('\x03', false);
+ // Wait a little before running the command to avoid the sequences being echoed while the ^C
+ // is being evaluated
+ await timeout(100);
+ }
+ // By default, use bracketed paste mode only when not running the command; callers can override
+ // this by explicitly enabling it via the bracketedPasteMode argument.
+ await this.sendText(commandLine, shouldExecute, !shouldExecute || forceBracketedPasteMode);
+ } finally {
+ console.log('Exiting TerminalInstance.runCommand');
+ }
}
detachFromElement(): void {