<commit_before>
const AppIntegrator = require('../../../lib/app-integrator');
const FakeEditorBuilder = require('../lib/fake-editor-builder');
const FakeVscodeBuilder = require('../lib/fake-vscode-builder');

suite('Highlight command', () => {

    const editorBuilder = new FakeEditorBuilder();
    const vscodeBuilder = new FakeVscodeBuilder();

    test('highlights selected text', async () => {
        const editors = [
            editorBuilder.build({
                wholeText: 'A TEXT B TEXT C',
                selectedText: 'TEXT'
            }),
            editorBuilder.build({
                wholeText: 'a TEXT'
            })
        ];
        const fakeContext = {subscriptions: []};
        const fakeVscode = vscodeBuilder.build({editors: editors});

        AppIntegrator.create(fakeVscode, console).integrate(fakeContext);

        const command = fakeVscode._commands['textmarker.toggleHighlight'];

        await command(editors[0]);

        expect(editors[0].setDecorations.args).to.eql([[
            'DECORATION_TYPE_1',
            [
                new fakeVscode.Range('POSITION:2', 'POSITION:6'),
                new fakeVscode.Range('POSITION:9', 'POSITION:13')
            ]
        ]]);
        expect(editors[1].setDecorations).to.have.been.calledWith(
            'DECORATION_TYPE_1',
            [
                new fakeVscode.Range('POSITION:2', 'POSITION:6')
            ]
        );
    });

});<commit_msg>ref #18 Added a test that reproduces the bug<commit_after>
const AppIntegrator = require('../../../lib/app-integrator');
const FakeEditorBuilder = require('../lib/fake-editor-builder');
const FakeVscodeBuilder = require('../lib/fake-vscode-builder');

suite('Highlight command', () => {

    let editor1;
    let editor2;
    let command;
    let fakeVscode;

    beforeEach(() => {
        const editorBuilder = new FakeEditorBuilder();
        const vscodeBuilder = new FakeVscodeBuilder();
        editor1 = editorBuilder.build({
            wholeText: 'A TEXT B TEXT C',
            selectedText: 'TEXT'
        });
        editor2 = editorBuilder.build({
            wholeText: 'a TEXT'
        });
        const fakeContext = {subscriptions: []};
        fakeVscode = vscodeBuilder.build({editors: [editor1, editor2]});

        AppIntegrator.create(fakeVscode, console).integrate(fakeContext);

        command = fakeVscode._commands['textmarker.toggleHighlight'];
    });

    test('highlights selected text', async () => {
        await command(editor1);

        expect(editor1.setDecorations.args).to.eql([[
            'DECORATION_TYPE_1',
            [
                new fakeVscode.Range('POSITION:2', 'POSITION:6'),
                new fakeVscode.Range('POSITION:9', 'POSITION:13')
            ]
        ]]);
        expect(editor2.setDecorations.args).to.eql([[
            'DECORATION_TYPE_1',
            [
                new fakeVscode.Range('POSITION:2', 'POSITION:6')
            ]
        ]]);
    });

    test.skip('unhighlight selected text if the exact text is already selected', async () => {
        await command(editor1);
        await command(editor1);

        expect(editor1.setDecorations.args[1]).to.eql([['DECORATION_TYPE_1', []]]);
        expect(editor2.setDecorations.args[1]).to.eql([['DECORATION_TYPE_1', []]]);
    });
});
{'fraction_non_alphanumeric': 0.14531202894181489, 'fraction_numerical': 0.012059089538739826, 'mean_word_length': 2.301492537313433, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '3224124', 'n_tokens_mistral': 1002, 'n_tokens_neox': 970, 'n_words': 165}