<commit_before>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { Uri, workspace } from 'vscode';
import { OmniSharpServer } from '../omnisharp/server';
import * as serverUtils from '../omnisharp/utils';
import { FileChangeType, LinePositionSpanTextChange } from '../omnisharp/protocol';
import { IDisposable } from '../Disposable';
import CompositeDisposable from '../CompositeDisposable';

function forwardDocumentChanges(server: OmniSharpServer): IDisposable {

    return workspace.onDidChangeTextDocument(event => {

        let { document } = event;
        if (document.isUntitled || document.languageId !== 'csharp' || document.uri.scheme !== 'file') {
            return;
        }

        if (!server.isRunning()) {
            return;
        }

        const lineChanges = event.contentChanges.map(function (change): LinePositionSpanTextChange {
            const range = change.range;
            return {
                NewText: change.text,
                StartLine: range.start.line + 1,
                StartColumn: range.start.character + 1,
                EndLine: range.end.line + 1,
                EndColumn: range.end.character + 1
            };
        });

        serverUtils.updateBuffer(server, { Changes: lineChanges, FileName: document.fileName }).catch(err => {<commit_msg>Revert "Make updateBuffer use incremental updates"<commit_after>/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

import { Uri, workspace } from 'vscode';
import { OmniSharpServer } from '../omnisharp/server';
import * as serverUtils from '../omnisharp/utils';
import { FileChangeType } from '../omnisharp/protocol';
import { IDisposable } from '../Disposable';
import CompositeDisposable from '../CompositeDisposable';

function forwardDocumentChanges(server: OmniSharpServer): IDisposable {

    return workspace.onDidChangeTextDocument(event => {

        let { document } = event;
        if (document.isUntitled || document.languageId !== 'csharp' || document.uri.scheme !== 'file') {
            return;
        }

        if (!server.isRunning()) {
            return;
        }

        serverUtils.updateBuffer(server, { Buffer: document.getText(), FileName: document.fileName }).catch(err => {
{'fraction_non_alphanumeric': 0.2346072186836518, 'fraction_numerical': 0.0014154281670205238, 'mean_word_length': 1.827, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '4532287', 'n_tokens_mistral': 677, 'n_tokens_neox': 643, 'n_words': 175}