mirror of
https://github.com/microsoft/vscode.git
synced 2026-08-29 17:41:32 +01:00
23 lines
991 B
TypeScript
23 lines
991 B
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
*--------------------------------------------------------------------------------------------*/
|
|
|
|
import { LineRange } from 'vs/editor/common/core/lineRange';
|
|
import { Range } from 'vs/editor/common/core/range';
|
|
import { ITextModel } from 'vs/editor/common/model';
|
|
|
|
export function invertLineRange(range: LineRange, model: ITextModel): LineRange[] {
|
|
if (range.isEmpty) {
|
|
return [];
|
|
}
|
|
const result: LineRange[] = [];
|
|
result.push(new LineRange(1, range.startLineNumber));
|
|
result.push(new LineRange(range.endLineNumberExclusive, model.getLineCount() + 1));
|
|
return result.filter(r => !r.isEmpty);
|
|
}
|
|
|
|
export function lineRangeAsRange(r: LineRange): Range {
|
|
return new Range(r.startLineNumber, 1, r.endLineNumberExclusive - 1, 1);
|
|
}
|