Skip to content

Commit 3cd5ca7

Browse files
authored
fix: Element inspector AI reference now works in Cursor (#1809)
#1732 used to only work in VSCode. This PR makes it work in Cursor. Support for other editors will be introduced in a separate PR, as right now, this feature cannot even be enabled on editors other than VSCode or Cursor due to how feature permissions & licensing are implemented. ### How Has This Been Tested: https://github.com/user-attachments/assets/cd49ffb0-fbd6-435c-9476-afadf4aecdf0 ### How Has This Change Been Documented: TBD: Will see if docs need updating
1 parent 0116ef8 commit 3cd5ca7

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/vscode-extension/src/project/project.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ import {
7272
import { AdminRestrictedFunctionalityError, PaywalledFunctionalityError } from "../common/Errors";
7373
import { Sentiment } from "../common/types";
7474
import { FeedbackGenerator } from "./feedbackGenerator";
75+
import { EditorType, getEditorType } from "../utilities/editorType";
7576

7677
const DEEP_LINKS_HISTORY_KEY = "deep_links_history";
7778

@@ -794,9 +795,19 @@ export class Project implements Disposable, ProjectInterface, DeviceSessionsMana
794795

795796
addToChatContext(...filePaths: string[]): void {
796797
try {
797-
commands.executeCommand("copilot-chat.focus").then(async () => {
798+
const editor = getEditorType();
799+
800+
let focusCommand = "copilot-chat.focus";
801+
let attachFileCommand = "workbench.action.chat.attachFile";
802+
803+
if (editor === EditorType.CURSOR) {
804+
focusCommand = "composer.startComposerPrompt";
805+
attachFileCommand = "composer.addfilestocomposer";
806+
}
807+
808+
commands.executeCommand(focusCommand).then(async () => {
798809
for (const filePath of filePaths) {
799-
await commands.executeCommand("workbench.action.chat.attachFile", Uri.file(filePath));
810+
await commands.executeCommand(attachFileCommand, Uri.file(filePath));
800811
}
801812
});
802813
} catch (e) {

0 commit comments

Comments
 (0)