p-doom/crowd-code-dataset-0.2 huggingface dataset:
[content] /home/franz.srambical/test_extension/test/src/extension.ts (typescript)

    // ---- Git extension state changes ----
    try {
        const gitExtension = vscode.extensions.getExtension('vscode.git')
        if (gitExtension) {
            if (!gitExtension.isActive) {
                gitExtension.activate().then(() => setupGitListeners(gitExtension, log))
            } else {
                setupGitListeners(gitExtension, log)
            }
        }
    } catch (e) {
        log(`GIT_EXTENSION_ERROR: ${e}`)
    }
}

function setupGitListeners(gitExtension: vscode.Extension<any>, log: (msg: string) => void) {
    try {
        const git = gitExtension.exports.getAPI(1)
        if (!git) return

        git.onDidChangeState(() => {
            log(`GIT_STATE_CHANGE state=${git.state}`)
        })

        // Watch each repository
        for (const repo of git.repositories) {
            repo.state.onDidChange(() => {
                log(
                    `GIT_REPO_STATE_CHANGE
  root=${repo.rootUri.toString()}
  HEAD=${repo.state.HEAD?.name ?? 'detached'}
  indexChanges=${repo.state.indexChanges.length}
  workingTreeChanges=${repo.state.workingTreeChanges.length}`
                )
            })
        }

        // Watch for new repositories
        git.onDidOpenRepository((repo: any) => {
            log(`GIT_REPO_OPENED root=${repo.rootUri.toString()}`)
            repo.state.onDidChange(() => {
                log(
                    `GIT_REPO_STATE_CHANGE
  root=${repo.rootUri.toString()}
  HEAD=${repo.state.HEAD?.name ?? 'detached'}
  indexChanges=${repo.state.indexChanges.length}
  workingTreeChanges=${repo.state.workingTreeChanges.length}`
                )
            })
        })
    } catch (e) {
        log(`GIT_LISTENER_ERROR: ${e}`)
    }
[content] /home/franz.srambical/test_extension/test/src/extension.ts (typescript)
    // ---- Document save ----
    context.subscriptions.push(
        vscode.workspace.onDidSaveTextDocument(doc => {
            const uri = doc.uri
            if (!isInWorkspace(uri)) return
            if (shouldIgnore(uri)) return

            log(
                `DOC_SAVE
  uri=${uri.toString()}
  version=${doc.version}`
            )
        })
    )

    // ---- Selection changes ----
    context.subscriptions.push(
        vscode.window.onDidChangeTextEditorSelection(event => {
            const uri = event.textEditor.document.uri
            if (!isInWorkspace(uri)) return
            if (shouldIgnore(uri)) return

            const sel = event.selections[0]
            const kindName = event.kind !== undefined
                ? ['Keyboard', 'Mouse', 'Command'][event.kind] ?? 'Unknown'
                : 'None'

            log(
                `SELECTION_CHANGE
  uri=${uri.toString()}
  kind=${kindName}
  anchor=${sel.anchor.line}:${sel.anchor.character}
  active=${sel.active.line}:${sel.active.character}
  isEmpty=${sel.isEmpty}`
            )
        })
    )

    // ---- Active editor change (TAB) ----
    context.subscriptions.push(
        vscode.window.onDidChangeActiveTextEditor(editor => {
            if (!editor) {
                log(`ACTIVE_EDITOR_CHANGE editor=none`)
                return
            }
            const uri = editor.document.uri
            if (!isInWorkspace(uri)) return
            if (shouldIgnore(uri)) return

            log(
                `ACTIVE_EDITOR_CHANGE
  uri=${uri.toString()}
  language=${editor.document.languageId}`
            )
        })
    )

    // ---- Terminal focus ----
    context.subscriptions.push(
        vscode.window.onDidChangeActiveTerminal(terminal => {
            log(`TERMINAL_FOCUS name=${terminal?.name ?? 'none'}`)
        })
    )

    // ---- Terminal shell execution (captures git commands run in terminal) ----
    context.subscriptions.push(
        vscode.window.onDidStartTerminalShellExecution(async event => {
            const commandLine = event.execution.commandLine.value
            log(
                `TERMINAL_COMMAND_START
  terminal=${event.terminal.name}
  command=${commandLine}`
            )

            // Stream terminal output
            const stream = event.execution.read()
            for await (const data of stream) {
                const preview = data.length > 200 ? data.slice(0, 200) + '...' : data
                log(
                    `TERMINAL_OUTPUT
  terminal=${event.terminal.name}
  data=${preview.replace(/
/g, '\
')}`
                )
            }
        })
    )
[content] /home/franz.srambical/test_extension/test/src/extension.ts (typescript)
            // Log detailed change info to help identify undo patterns
            const changeDetails = event.contentChanges.map((c, i) => {
                const textPreview = c.text.length > 50 ? c.text.slice(0, 50) + '...' : c.text
                return `  change[${i}]: offset=${c.rangeOffset} len=${c.rangeLength} text="${textPreview.replace(/
/g, '\
')}"`
            }).join('
')
[content] /home/franz.srambical/test_extension/test/src/extension.ts (typescript)
    // ---- Command execution tracking (undo/redo/git commands) ----
    context.subscriptions.push(
        vscode.commands.onDidExecuteCommand(event => {
            // Log all commands if they're in our interesting set, or if they contain 'git' or 'undo' or 'redo'
            const cmd = event.command
            const isInteresting = INTERESTING_COMMANDS.has(cmd) ||
                cmd.toLowerCase().includes('undo') ||
                cmd.toLowerCase().includes('redo') ||
                cmd.toLowerCase().includes('git')

            if (isInteresting) {
                log(
                    `COMMAND_EXECUTED
  command=${cmd}
  args=${JSON.stringify(event.arguments ?? [])}`
                )
            }
        })
    )

    // ---- Text document changes (with more detail for undo detection) ----
[content] /home/franz.srambical/test_extension/test/src/extension.ts (typescript)
// Commands we care about for undo/redo/git tracking
const INTERESTING_COMMANDS = new Set([
    'undo',
    'redo',
    'editor.action.undo',
    'editor.action.redo',
    'git.pull',
    'git.pullRebase',
    'git.push',
    'git.stash',
    'git.stashPop',
    'git.stashApply',
    'git.stashDrop',
    'git.checkout',
    'git.branch',
    'git.merge',
    'git.rebase',
    'git.fetch',
    'git.commit',
    'git.commitStaged',
    'git.stage',
    'git.unstage',
    'git.clean',
    'git.reset',
    'git.revert',
])
[content] /home/franz.srambical/test_extension/test/src/extension.ts (typescript)
    // NOTE: vscode.commands.onDidExecuteCommand is NOT available in the stable API.
    // Undo/redo operations will appear as TEXT_CHANGE events with reason=1 (Undo) or reason=2 (Redo).
    // Git commands via VS Code UI will trigger GIT_REPO_STATE_CHANGE events.
    // Git commands via terminal will trigger TERMINAL_COMMAND_START events.

    // ---- Text document changes (with more detail for undo detection) ----