1
>
/*---------------------------------------------------------------------------------------------
cursorColumns.ts
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
>
import { CharCode } from '../../../base/common/charCode.js';
7
>
import * as strings from '../../../base/common/strings.js';
8
>
9
>
/**
10
>
* A column in a position is the gap between two adjacent characters. The methods here
11
>
* work with a concept called "visible column". A visible column is a very rough approximation
12
>
* of the horizontal screen position of a column. For example, using a tab size of 4:
13
>
* ```txt
14
>
* |<TAB>|<TAB>|T|ext
15
>
* | | | \---- column = 4, visible column = 9
16
>
* | | \------ column = 3, visible column = 8
17
>
* | \------------ column = 2, visible column = 4
18
>
* \------------------ column = 1, visible column = 0
19
>
* ```
20
>
*
21
>
* **NOTE**: Visual columns do not work well for RTL text or variable-width fonts or characters.
22
>
*
23
>
* **NOTE**: These methods work and make sense both on the model and on the view model.
24
>
*/
25
>
export class CursorColumns {
26
>
27
>
private static _nextVisibleColumn(codePoint: number, visibleColumn: number, tabSize: number): number {
28
if (codePoint === CharCode.Tab) {
29
return CursorColumns.nextRenderTabStop(visibleColumn, tabSize);