Path: blob/main/extensions/copilot/src/extension/prompts/node/test/adjustSelection.spec.ts
13405 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/456import { describe, expect, it } from 'vitest';7import { StringTextDocument } from '../../../../platform/editing/common/abstractText';8import { getStructureUsingIndentation } from '../../../../platform/parser/node/indentationStructure';9import { Position, Range } from '../../../../vscodeTypes';10import { getAdjustedSelection } from '../inline/adjustSelection';1112describe('adjustSelection', () => {1314it('should adjust selection in Swift code', async () => {1516const code = `import Foundation\nimport CoreMotion\n\n`;1718const doc = new StringTextDocument(code);1920const ast = getStructureUsingIndentation(doc, 'swift', undefined);21const selection = new Range(new Position(3, 0), new Position(3, 0));2223const result = getAdjustedSelection(ast, doc, selection);24expect(result.adjusted.toString()).toMatchInlineSnapshot(`"[36, 37)"`);25});26});272829