Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/extensions/copilot/src/extension/prompts/node/test/adjustSelection.spec.ts
13405 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
7
import { describe, expect, it } from 'vitest';
8
import { StringTextDocument } from '../../../../platform/editing/common/abstractText';
9
import { getStructureUsingIndentation } from '../../../../platform/parser/node/indentationStructure';
10
import { Position, Range } from '../../../../vscodeTypes';
11
import { getAdjustedSelection } from '../inline/adjustSelection';
12
13
describe('adjustSelection', () => {
14
15
it('should adjust selection in Swift code', async () => {
16
17
const code = `import Foundation\nimport CoreMotion\n\n`;
18
19
const doc = new StringTextDocument(code);
20
21
const ast = getStructureUsingIndentation(doc, 'swift', undefined);
22
const selection = new Range(new Position(3, 0), new Position(3, 0));
23
24
const result = getAdjustedSelection(ast, doc, selection);
25
expect(result.adjusted.toString()).toMatchInlineSnapshot(`"[36, 37)"`);
26
});
27
});
28
29