<commit_before>
import {Column} from "../entities/column";
import {RowNode} from "../entities/rowNode";
import {Autowired, Bean, PostConstruct} from "../context/context";
import {GridOptionsWrapper} from "../gridOptionsWrapper";
import {ChangedPath} from "../rowModels/inMemory/changedPath";
import {IRowModel} from "../interfaces/iRowModel";
import {InMemoryRowModel} from "../rowModels/inMemory/inMemoryRowModel";
import {RowRenderer} from "../rendering/rowRenderer";
import {EventService} from "../eventService";
import {Constants} from "../constants";
import {BeanStub} from "../context/beanStub";
import {Events} from "../events";

@Bean('changeDetectionService')
export class ChangeDetectionService extends BeanStub {

    @Autowired('gridOptionsWrapper') private gridOptionsWrapper: GridOptionsWrapper;
    @Autowired('rowModel') private rowModel: IRowModel;
    @Autowired('rowRenderer') private rowRenderer: RowRenderer;
    @Autowired('eventService') private eventService: EventService;

    private inMemoryRowModel: InMemoryRowModel;

    @PostConstruct
    private init(): void {
        if (this.rowModel.getType()===Constants.ROW_MODEL_TYPE_IN_MEMORY) {
            this.inMemoryRowModel = <InMemoryRowModel> this.rowModel;
        }

        this.addDestroyableEventListener(this.eventService, Events.EVENT_CELL_VALUE_CHANGED, this.onCellValueChanged.bind(this));
    }

    private onCellValueChanged(event: any): void {
        this.doChangeDetection(event.node, event.column);
    }

    private doChangeDetection(rowNode: RowNode, column: Column): void {
        if (this.gridOptionsWrapper.isSuppressChangeDetection()) { return; }

        // step 1 of change detection is to update the aggregated values
        if (this.inMemoryRowModel) {

            let changedPath: ChangedPath;
            if (rowNode.parent) {
                let onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns();
                changedPath = new ChangedPath(onlyChangedColumns);
                changedPath.addParentNode(rowNode.parent, [column]);
            }

            this.inMemoryRowModel.doAggregate(changedPath);
        }

        // step 2 of change detection is to refresh the cells
        this.rowRenderer.refreshCells();
    }

}<commit_msg>AG-1666 Editing cells in pinned rows results in 'isActive' error<commit_after>
import {Column} from "../entities/column";
import {RowNode} from "../entities/rowNode";
import {Autowired, Bean, PostConstruct} from "../context/context";
import {GridOptionsWrapper} from "../gridOptionsWrapper";
import {ChangedPath} from "../rowModels/inMemory/changedPath";
import {IRowModel} from "../interfaces/iRowModel";
import {InMemoryRowModel} from "../rowModels/inMemory/inMemoryRowModel";
import {RowRenderer} from "../rendering/rowRenderer";
import {EventService} from "../eventService";
import {Constants} from "../constants";
import {BeanStub} from "../context/beanStub";
import {Events} from "../events";

@Bean('changeDetectionService')
export class ChangeDetectionService extends BeanStub {

    @Autowired('gridOptionsWrapper') private gridOptionsWrapper: GridOptionsWrapper;
    @Autowired('rowModel') private rowModel: IRowModel;
    @Autowired('rowRenderer') private rowRenderer: RowRenderer;
    @Autowired('eventService') private eventService: EventService;

    private inMemoryRowModel: InMemoryRowModel;

    @PostConstruct
    private init(): void {
        if (this.rowModel.getType()===Constants.ROW_MODEL_TYPE_IN_MEMORY) {
            this.inMemoryRowModel = <InMemoryRowModel> this.rowModel;
        }

        this.addDestroyableEventListener(this.eventService, Events.EVENT_CELL_VALUE_CHANGED, this.onCellValueChanged.bind(this));
    }

    private onCellValueChanged(event: any): void {
        this.doChangeDetection(event.node, event.column);
    }

    private doChangeDetection(rowNode: RowNode, column: Column): void {
        if (this.gridOptionsWrapper.isSuppressChangeDetection()) { return; }

        // step 1 of change detection is to update the aggregated values
        if (this.inMemoryRowModel && !rowNode.isRowPinned()) {
            let onlyChangedColumns = this.gridOptionsWrapper.isAggregateOnlyChangedColumns();
            let changedPath = new ChangedPath(onlyChangedColumns);
            changedPath.addParentNode(rowNode.parent, [column]);
            this.inMemoryRowModel.doAggregate(changedPath);
        }

        // step 2 of change detection is to refresh the cells
        this.rowRenderer.refreshCells();
    }

}
{'fraction_non_alphanumeric': 0.1140215716486903, 'fraction_numerical': 0.0017609509134932863, 'mean_word_length': 3.9124324324324324, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1780627', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1230, 'n_words': 288}