Skip to content

Commit

Permalink
Chat: don't add selection to chat on option+l shortcut (#5310)
Browse files Browse the repository at this point in the history
Previously, the option+l shortcut triggered two commands:

- Toggle chat
- Add selection to chat

This was problematic because the selection is already an initial context
in chat so the chat input ended up having duplicate chips (one "initial"
    and one "user").

This PR fixes the problem by removing the option+l shortcut for "Add
selection to chat" so that it only toggles the visibility of the
sidebar. Users can still manually add the selection to the chat input
with the option+/ shortcut.

## Test plan

* Local build
* Select text
* Trigger option+l multiple times
* Confirm that it doesn't keep adding the selection to the chat
<!-- Required. See
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles.
-->

## Changelog

* Fix bug where continuously triggering alt+l (option+l for macOS) would
add duplicate context items to the chat input. Use the alt+/ shortcut to
explicitly add the selection to the chat input.
<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
  • Loading branch information
olafurpg authored Aug 23, 2024
1 parent d6c5496 commit 2797775
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
5 changes: 0 additions & 5 deletions vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -647,11 +647,6 @@
"key": "alt+/",
"when": "cody.activated && editorTextFocus && editorHasSelection"
},
{
"command": "cody.mention.selection",
"key": "alt+l",
"when": "cody.activated && editorTextFocus && editorHasSelection"
},
{
"command": "cody.tutorial.chat",
"key": "alt+l",
Expand Down
2 changes: 1 addition & 1 deletion vscode/test/e2e/chat-keyboard-shortcuts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@ test('chat keyboard shortcuts for sidebar chat', async ({ page, sidebar }) => {

// Alt+L with a selection opens a new chat (with selection mention).
await selectLineRangeInEditorTab(page, 3, 5)
await page.keyboard.press('Alt+L')
await page.keyboard.press('Alt+/')
await expect(chatSidebarInput).toContainText('buzz.ts buzz.ts:3-5 ')
})

0 comments on commit 2797775

Please sign in to comment.