Roo-Code/src/activate
Murilo Pires 9bf31d3ff7
fix terminal keyboard shortcut error when adding content to context (#5161)
## Fix terminal keyboard shortcut error when adding content to context

**Fixes:** [#2276](https://github.com/RooCodeInc/Roo-Code/issues/2276)

**Problem:**
- Using keyboard shortcuts to add terminal content to context threw error: "Cannot read properties of undefined (reading 'selection')"
- Context menu worked correctly, but keyboard shortcuts failed

**Root Cause:**
- Command handler accessed `args.selection` without null checking
- When triggered via keyboard shortcut, VS Code passes `undefined` for `args` parameter
- When triggered via context menu, VS Code passes an object with `selection` property

**Solution:**
- Changed `args.selection` to `args?.selection` using optional chaining
- Maintains existing fallback behavior when no selection is available
- Preserves backward compatibility with context menu functionality

**Files Modified:**
- `src/activate/registerTerminalActions.ts` - Added null safety for args parameter

**Testing:**
-  Keyboard shortcuts now work without errors
-  Context menu functionality preserved
-  Fallback to `Terminal.getTerminalContents()` works in both scenarios
2025-06-26 20:34:14 -04:00
..
__tests__ fix: Handle long Claude code messages (#5072) 2025-06-24 11:34:06 -04:00
CodeActionProvider.ts Added Enable Roo Code quick fixes setting to disable quick fixes. (#4878) 2025-06-23 18:41:57 -04:00
handleTask.ts Add a new @roo-code/types package and use it everywhere (#3912) 2025-05-26 12:06:45 -07:00
handleUri.ts Store the organization id in credentials (#5002) 2025-06-23 07:23:29 -04:00
humanRelay.ts Follow the established pattern for command registration 2025-03-10 11:12:11 -07:00
index.ts Move presentAssistantMessage into its own module (#3345) 2025-05-08 11:59:03 -07:00
registerCodeActions.ts Add a new @roo-code/types package and use it everywhere (#3912) 2025-05-26 12:06:45 -07:00
registerCommands.ts feat: register importSettings as VSCode command (#5095) 2025-06-25 16:07:08 -04:00
registerTerminalActions.ts fix terminal keyboard shortcut error when adding content to context (#5161) 2025-06-26 20:34:14 -04:00