Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,11 +941,26 @@
"description": "Text direction for the editor (left-to-right or right-to-left)"
},
"codex-editor-extension.cellsPerPage": {
"title": "Cells Per Page",
"type": "number",
"default": 50,
"minimum": 5,
"maximum": 200,
"description": "Number of cells to display per page when a chapter has many cells. Helps with performance for large chapters."
"description": "Default page size for milestones without custom subdivision breaks. Applies only as a fallback when a milestone has no user-defined subdivisions."
},
"codex-editor-extension.useSubdivisionNumberLabels": {
"title": "Always Show Subdivision Number Ranges",
"type": "boolean",
"default": false,
"description": "When enabled, milestone subdivisions always display their numeric cell range (e.g. '6-15') even if a user-assigned name exists. When disabled, names take precedence and the range is shown only as a muted suffix."
},
"codex-editor-extension.maxSubdivisionLength": {
"title": "Maximum Subdivision Length",
"type": "number",
"default": 0,
"minimum": 0,
"maximum": 5000,
"description": "Maximum number of cells the editor will leave inside a single subdivision. Stretches between user-defined breaks that exceed this length are sub-chunked using 'Cells Per Page'. Set to 0 to disable (in which case 'Cells Per Page' itself acts as the threshold). Useful when you want a higher 'Cells Per Page' default but still allow short logical pages between custom breaks to remain unbroken."
},
"codex-editor-extension.useOnlyValidatedExamples": {
"title": "Use Only Validated Examples",
Expand Down
69 changes: 69 additions & 0 deletions src/interfaceSettings/interfaceSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,20 @@ export async function openInterfaceSettings() {
const sendInit = () => {
const config = vscode.workspace.getConfiguration("codex-editor-extension");
const highlightSearchResults = config.get<boolean>("highlightSearchResults", true);
const cellsPerPage = config.get<number>("cellsPerPage", 50);
const useSubdivisionNumberLabels = config.get<boolean>(
"useSubdivisionNumberLabels",
false
);
const maxSubdivisionLength = config.get<number>("maxSubdivisionLength", 0);

panel.webview.postMessage({
command: "init",
data: {
highlightSearchResults,
cellsPerPage,
useSubdivisionNumberLabels,
maxSubdivisionLength,
},
});
};
Expand Down Expand Up @@ -99,6 +108,66 @@ export async function openInterfaceSettings() {
);
break;
}

case "updateCellsPerPage": {
// Clamp to the range declared in package.json so invalid input
// cannot corrupt pagination. Pull bounds from the schema-defined
// minimum/maximum rather than hardcoding them in multiple places.
const raw = Number(message.value);
if (!Number.isFinite(raw)) break;
const clamped = Math.max(5, Math.min(200, Math.round(raw)));
const config = vscode.workspace.getConfiguration("codex-editor-extension");
await config.update(
"cellsPerPage",
clamped,
vscode.ConfigurationTarget.Workspace
);
break;
}

case "updateUseSubdivisionNumberLabels": {
const config = vscode.workspace.getConfiguration("codex-editor-extension");
await config.update(
"useSubdivisionNumberLabels",
Boolean(message.value),
vscode.ConfigurationTarget.Workspace
);
break;
}

case "updateMaxSubdivisionLength": {
// 0 means "off" — the resolver falls back to using `cellsPerPage`
// as the threshold. Anything else is clamped to the package.json
// bounds so corrupted input can't sneak through.
const raw = Number(message.value);
if (!Number.isFinite(raw)) break;
const rounded = Math.round(raw);
const clamped = rounded <= 0 ? 0 : Math.max(0, Math.min(5000, rounded));
const config = vscode.workspace.getConfiguration("codex-editor-extension");
await config.update(
"maxSubdivisionLength",
clamped,
vscode.ConfigurationTarget.Workspace
);
break;
}
}
});

// Keep the panel in sync when settings change from elsewhere (e.g. the
// VS Code Settings UI). Disposed together with the panel below.
const configListener = vscode.workspace.onDidChangeConfiguration((e) => {
if (
e.affectsConfiguration("codex-editor-extension.highlightSearchResults") ||
e.affectsConfiguration("codex-editor-extension.cellsPerPage") ||
e.affectsConfiguration("codex-editor-extension.useSubdivisionNumberLabels") ||
e.affectsConfiguration("codex-editor-extension.maxSubdivisionLength")
) {
sendInit();
}
});

panel.onDidDispose(() => {
configListener.dispose();
});
}
Loading
Loading