mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-10 14:10:37 -07:00
feat: autogenerate keyboard shortcut docs (#12944)
This commit is contained in:
@@ -81,3 +81,39 @@ export function formatDefaultValue(
|
||||
return String(value);
|
||||
}
|
||||
}
|
||||
|
||||
interface MarkerInsertionOptions {
|
||||
document: string;
|
||||
startMarker: string;
|
||||
endMarker: string;
|
||||
newContent: string;
|
||||
paddingBefore?: string;
|
||||
paddingAfter?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces the content between two markers with `newContent`, preserving the
|
||||
* original document outside the markers and applying optional padding.
|
||||
*/
|
||||
export function injectBetweenMarkers({
|
||||
document,
|
||||
startMarker,
|
||||
endMarker,
|
||||
newContent,
|
||||
paddingBefore = '\n',
|
||||
paddingAfter = '\n',
|
||||
}: MarkerInsertionOptions): string {
|
||||
const startIndex = document.indexOf(startMarker);
|
||||
const endIndex = document.indexOf(endMarker);
|
||||
|
||||
if (startIndex === -1 || endIndex === -1 || startIndex >= endIndex) {
|
||||
throw new Error(
|
||||
`Could not locate documentation markers (${startMarker}, ${endMarker}).`,
|
||||
);
|
||||
}
|
||||
|
||||
const before = document.slice(0, startIndex + startMarker.length);
|
||||
const after = document.slice(endIndex);
|
||||
|
||||
return `${before}${paddingBefore}${newContent}${paddingAfter}${after}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user