shifting towards manual symlinks for more complex setup than laptop, allows for GUI settings changes to actually apply, and is much easier than nix-ifying every config
127 lines
4.9 KiB
JavaScript
127 lines
4.9 KiB
JavaScript
"use strict";
|
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
}
|
|
Object.defineProperty(o, k2, desc);
|
|
}) : (function(o, m, k, k2) {
|
|
if (k2 === undefined) k2 = k;
|
|
o[k2] = m[k];
|
|
}));
|
|
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
}) : function(o, v) {
|
|
o["default"] = v;
|
|
});
|
|
var __importStar = (this && this.__importStar) || (function () {
|
|
var ownKeys = function(o) {
|
|
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
var ar = [];
|
|
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
return ar;
|
|
};
|
|
return ownKeys(o);
|
|
};
|
|
return function (mod) {
|
|
if (mod && mod.__esModule) return mod;
|
|
var result = {};
|
|
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
})();
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.activate = activate;
|
|
exports.deactivate = deactivate;
|
|
const vscode = __importStar(require("vscode"));
|
|
const storage = __importStar(require("./storage"));
|
|
const searchCtx = __importStar(require("./searchCtx"));
|
|
const WebviewManager_1 = require("./webview/WebviewManager");
|
|
/**
|
|
* Called when the extension is activated
|
|
*/
|
|
function activate(context) {
|
|
console.log('PatternStore extension is now active!');
|
|
// Register command: Manage Patterns
|
|
const manageCommand = vscode.commands.registerCommand('patternStore.manage', async () => {
|
|
await managePatternsCommand(context.extensionUri);
|
|
});
|
|
context.subscriptions.push(manageCommand);
|
|
}
|
|
/**
|
|
* Called when the extension is deactivated
|
|
*/
|
|
function deactivate() {
|
|
console.log('PatternStore extension is now deactivated');
|
|
}
|
|
/**
|
|
* Command: Save the current search state as a pattern
|
|
*/
|
|
async function savePatternCommand() {
|
|
try {
|
|
vscode.window.showInformationMessage('PatternStore: Save Pattern command executed!');
|
|
// Get current search state
|
|
const searchState = await searchCtx.getCurrentSearchState();
|
|
if (!searchState) {
|
|
vscode.window.showErrorMessage('Could not read current search state');
|
|
return;
|
|
}
|
|
// Prompt for pattern name
|
|
const label = await vscode.window.showInputBox({
|
|
prompt: 'Enter a name for this pattern',
|
|
placeHolder: 'e.g., "Replace quotes with angles"',
|
|
validateInput: (value) => {
|
|
if (!value || value.trim().length === 0) {
|
|
return 'Pattern name cannot be empty';
|
|
}
|
|
return null;
|
|
}
|
|
});
|
|
if (!label) {
|
|
return; // User cancelled
|
|
}
|
|
// Ask for scope
|
|
const scopeChoice = await vscode.window.showQuickPick([
|
|
{ label: 'Global', description: 'Available in all workspaces', value: 'global' },
|
|
{ label: 'Workspace', description: 'Only for this workspace', value: 'workspace' }
|
|
], { placeHolder: 'Choose storage scope' });
|
|
if (!scopeChoice) {
|
|
return; // User cancelled
|
|
}
|
|
// Create pattern object
|
|
const pattern = {
|
|
id: 'new', // Temporary ID for new patterns
|
|
label: label.trim(),
|
|
find: searchState.find || '',
|
|
replace: searchState.replace || '',
|
|
flags: searchState.flags || {
|
|
isRegex: false,
|
|
isCaseSensitive: false,
|
|
matchWholeWord: false,
|
|
isMultiline: false
|
|
},
|
|
scope: scopeChoice.value
|
|
};
|
|
// Check if pattern exists (will check when we implement storage)
|
|
const exists = storage.patternExists(pattern.label, pattern.scope);
|
|
if (exists) {
|
|
const overwrite = await vscode.window.showWarningMessage(`A pattern named "${pattern.label}" already exists. Overwrite?`, 'Yes', 'No');
|
|
if (overwrite !== 'Yes') {
|
|
return;
|
|
}
|
|
}
|
|
// Save pattern
|
|
await storage.savePattern(pattern);
|
|
}
|
|
catch (error) {
|
|
vscode.window.showErrorMessage(`Error saving pattern: ${error}`);
|
|
}
|
|
}
|
|
async function managePatternsCommand(extensionUri) {
|
|
console.log('Manage Patterns command pressed - opening webview');
|
|
// For now, just open global patterns. We'll add separate commands later
|
|
WebviewManager_1.WebviewManager.show(extensionUri, 'global');
|
|
}
|
|
//# sourceMappingURL=extension.js.map
|