LCOV - code coverage report
Current view: top level - dashql-app/src/session/scripts - script_rename.ts Coverage Total Hit
Test: DashQL 915828b Lines: 100.0 % 13 13
Test Date: 2026-11-06 19:30:32

            Line data    Source code
       1              : import { RENAME_SCRIPT, type SessionScripts } from './session_scripts.js';
       2              : import type { ModifySessionScripts } from './session_scripts_registry.js';
       3              : import { scriptDisplayName } from './script_types.js';
       4              : 
       5              : /// Renames the references to a script in a draft, by display names
       6              : export type RenameDraftReferences = (from: string, to: string) => void;
       7              : 
       8              : /// Rename a script. The reducer rewrites the references in the other scripts, the draft follows once the name is
       9              : /// final, the reducer disambiguates it.
      10            1 : export async function renameScript(
      11            1 :     session: SessionScripts,
      12            1 :     modify: ModifySessionScripts,
      13            1 :     fileName: string,
      14            1 :     newFileName: string,
      15            1 :     renameDraft: RenameDraftReferences | null | undefined,
      16            1 : ): Promise<void> {
      17            1 :     const scriptId = session.scriptRefs[fileName]?.scriptId;
      18            1 :     const next = await modify({ type: RENAME_SCRIPT, value: { fileName, newFileName } });
      19            1 :     const renamed = scriptId != null ? next?.scripts[scriptId]?.fileName : undefined;
      20            1 :     if (renamed != null && renamed !== fileName) {
      21            1 :         renameDraft?.(scriptDisplayName(fileName), scriptDisplayName(renamed));
      22              :     }
      23            1 : }
        

Generated by: LCOV version 2.0-1