Path: blob/main/extensions/copilot/src/extension/inlineEdits/vscode-node/utils/translations.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*--------------------------------------------------------------------------------------------*/45import * as vscode from 'vscode';6import { Range } from '../../../../util/vs/editor/common/core/range';7import { Position } from '../../../../util/vs/editor/common/core/position';8import { TextReplacement } from '../../../../util/vs/editor/common/core/edits/textEdit';910export function toInternalRange(range: vscode.Range): Range {11return new Range(range.start.line + 1, range.start.character + 1, range.end.line + 1, range.end.character + 1);12}1314export function toExternalRange(range: Range): vscode.Range {15return new vscode.Range(toExternalPosition(range.getStartPosition()), toExternalPosition(range.getEndPosition()));16}1718export function toInternalPosition(position: vscode.Position): Position {19return new Position(position.line + 1, position.character + 1);20}2122export function toExternalPosition(position: Position): vscode.Position {23return new vscode.Position(position.lineNumber - 1, position.column - 1);24}2526export function toInternalTextEdit(range: vscode.Range, newText: string): TextReplacement {27return new TextReplacement(toInternalRange(range), newText);28}2930export function toExternalTextEdit(edit: TextReplacement): vscode.TextEdit {31return new vscode.TextEdit(toExternalRange(edit.range), edit.text);32}3334