| 1 |
- "use strict";var $=Object.create;var d=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var b=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,S=Object.prototype.hasOwnProperty;var U=(e,o)=>{for(var t in o)d(e,t,{get:o[t],enumerable:!0})},p=(e,o,t,c)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of b(o))!S.call(e,s)&&s!==t&&d(e,s,{get:()=>o[s],enumerable:!(c=C(o,s))||c.enumerable});return e};var u=(e,o,t)=>(t=e!=null?$(k(e)):{},p(o||!e||!e.__esModule?d(t,"default",{value:e,enumerable:!0}):t,e)),T=e=>p(d({},"__esModule",{value:!0}),e);var W={};U(W,{activate:()=>E,deactivate:()=>M});module.exports=T(W);var n=u(require("vscode"));var i=u(require("vscode"));function v(e){return`[${e}]`}function R(e,o,t,c,s){return`[${`${e} L${o}C${t}-L${c}C${s}`}]`}function D(e){return e.map(o=>v(o.filePath)).join("")}async function f(){let e=i.window.activeTextEditor;if(!e)return;let o=e.selection;if(o.isEmpty)return;let t=e.document,c=i.workspace.asRelativePath(t.uri),s=o.start.line+1,r=o.start.character+1,a=o.end.line+1,P=o.end.character+1,g=R(c,s,r,a,P);await i.env.clipboard.writeText(g),l(`$(clippy) Copied ${c}:${s}-${a}`)}async function m(){let e=i.window.activeTextEditor;if(!e)return;let o=e.document,t=i.workspace.asRelativePath(o.uri),c=v(t);await i.env.clipboard.writeText(c),l(`$(clippy) Copied file: ${t}`)}async function y(){let e=i.workspace.workspaceFolders;if(!e||e.length===0)return;let o=await i.window.showOpenDialog({canSelectFiles:!0,canSelectFolders:!1,canSelectMany:!0,openLabel:"Select files to copy as context"});!o||o.length===0||await F(o)}async function h(e){let o=i.workspace.asRelativePath(e),t=`[${o}]`;await i.env.clipboard.writeText(t),l(`$(clippy) Copied folder: ${o}`)}async function w(e){!e||e.length===0||await F(e)}async function x(e){let o=[],t=await i.workspace.fs.readDirectory(e);for(let[c,s]of t){let r=i.Uri.joinPath(e,c);if(s===i.FileType.Directory){let a=await x(r);o.push(...a)}else s===i.FileType.File&&o.push(r)}return o}async function L(e){let o=[];for(let t of e)try{let c=await i.workspace.fs.stat(t);if(c.type===i.FileType.Directory){let s=await x(t);o.push(...s)}else c.type===i.FileType.File&&o.push(t)}catch{}return o}async function F(e){let o=await L(e),t=[];for(let s of o)try{await i.workspace.openTextDocument(s);let r=i.workspace.asRelativePath(s);t.push({filePath:r})}catch{}if(t.length===0)return;let c=D(t);await i.env.clipboard.writeText(c),l(`$(clippy) Copied ${t.length} file(s)`)}function l(e){i.window.setStatusBarMessage(e,3e3)}function E(e){console.log("[vsix-cp-ai-ctx] activating..."),e.subscriptions.push(n.commands.registerCommand("vsix-cp-ai-ctx.copySelection",()=>{f()})),e.subscriptions.push(n.commands.registerCommand("vsix-cp-ai-ctx.copyFile",()=>{m()})),e.subscriptions.push(n.commands.registerCommand("vsix-cp-ai-ctx.copyWorkspaceFiles",()=>{y()})),e.subscriptions.push(n.commands.registerCommand("vsix-cp-ai-ctx.copySelectedFiles",o=>{if(!o)return;if(o instanceof n.Uri){h(o);return}let t=o.selectedResources||[];w(t)})),console.log("[vsix-cp-ai-ctx] activated")}function M(){}0&&(module.exports={activate,deactivate});
|