Filehigh importancesource

ideDiffConfig.ts

components/permissions/FilePermissionDialog/ideDiffConfig.ts

43
Lines
858
Bytes
5
Exports
1
Imports
10
Keywords

What this is

This page documents one file from the repository and includes its full source so you can read it without leaving the docs site.

Beginner explanation

This file is one piece of the larger system. Its name, directory, imports, and exports show where it fits. Start by reading the exports and related files first.

How it is used

Start from the exports list and related files. Those are the easiest clues for where this file fits into the system.

Expert explanation

Architecturally, this file intersects with file-tools, shell-safety, permissions, ui-flow. It contains 43 lines, 1 detected imports, and 5 detected exports.

Important relationships

Detected exports

  • FileEdit
  • IDEDiffConfig
  • IDEDiffChangeInput
  • IDEDiffSupport
  • createSingleEditDiffConfig

Keywords

interfacefileedittinputidediffconfigfilepatheditstoolinputold_stringnew_stringreplace_all

Detected imports

  • ./useFilePermissionDialog.js

Source notes

This page embeds the full file contents. Small or leaf files are still indexed honestly instead of being over-explained.

Open parent directory

Full source

import type { ToolInput } from './useFilePermissionDialog.js'

export interface FileEdit {
  old_string: string
  new_string: string
  replace_all?: boolean
}

export interface IDEDiffConfig {
  filePath: string
  edits?: FileEdit[]
  editMode?: 'single' | 'multiple'
}

export interface IDEDiffChangeInput {
  file_path: string
  edits: FileEdit[]
}

export interface IDEDiffSupport<TInput extends ToolInput> {
  getConfig(input: TInput): IDEDiffConfig
  applyChanges(input: TInput, modifiedEdits: FileEdit[]): TInput
}

export function createSingleEditDiffConfig(
  filePath: string,
  oldString: string,
  newString: string,
  replaceAll?: boolean,
): IDEDiffConfig {
  return {
    filePath,
    edits: [
      {
        old_string: oldString,
        new_string: newString,
        replace_all: replaceAll,
      },
    ],
    editMode: 'single',
  }
}