|
|
@@ -7,6 +7,27 @@ import {
|
|
|
copyMultiFiles,
|
|
|
} from './copyContext';
|
|
|
|
|
|
+function copySmart() {
|
|
|
+ // 1. Editor has selection → copy selection
|
|
|
+ const editor = vscode.window.activeTextEditor;
|
|
|
+ if (editor && !editor.selection.isEmpty) {
|
|
|
+ copySelection();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 2. Editor focused but no selection → copy current file
|
|
|
+ if (editor) {
|
|
|
+ copyActiveFile();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 3. Explorer focused → try to get selection from active editor as fallback
|
|
|
+ const fallbackEditor = vscode.window.activeTextEditor;
|
|
|
+ if (fallbackEditor) {
|
|
|
+ copyActiveFile();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
export function activate(context: vscode.ExtensionContext) {
|
|
|
console.log('[copy-ai-ctx] activating...');
|
|
|
|
|
|
@@ -22,6 +43,12 @@ export function activate(context: vscode.ExtensionContext) {
|
|
|
}),
|
|
|
);
|
|
|
|
|
|
+ context.subscriptions.push(
|
|
|
+ vscode.commands.registerCommand('copy-ai-ctx.copySmart', () => {
|
|
|
+ copySmart();
|
|
|
+ }),
|
|
|
+ );
|
|
|
+
|
|
|
context.subscriptions.push(
|
|
|
vscode.commands.registerCommand('copy-ai-ctx.copySelectedFiles', (args) => {
|
|
|
if (!args) {
|