cursorColumns.ts ×9

Frontier kind: Code frontier

unlabeled · c_a97e7b823736

877 tests · 5070 LOC · 27 files · introduces 0 tests · 70 LOC · 1 file

Introduces — evidence that enters the hierarchy at this concept

Code
9 ranges70 lines · 1 files
Tests
0 tests

Contains — complete concept membership

All code (extent)
735 ranges5070 lines · 27 files · Browse complete extent
All tests (intent)
877 testsBrowse complete intent

Neighbourhood graph

The orange circle is the focus. Violet and green circles are every ancestor and descendant, broader and narrower, at any distance; blue squares and pink diamonds are the introduced files and exact introduced tests of every visible concept, not only the focus's. Arrows point from broader to narrower concepts and bridge only concepts omitted from this view. Undirected links show source or test introduction. Concept and file size follows LOC; exact test nodes use test-count units.

Introduced files, introduced tests, and structurally relevant concept specialization

In the embedded map, ordinary wheel input scrolls the page; use the visible controls to zoom and drag to pan. Open the full-screen map for canvas navigation: wheel pans, Ctrl/Command plus wheel zooms, and arrow keys pan when this region is focused. On touch screens, open the full-screen map to pan or pinch. If JavaScript or WebGL is unavailable, use the native relationship evidence on this page.

Graph controls are ready.

Interactive rendering requires JavaScript and WebGL. Use the native relationship evidence on this page while the interactive map is unavailable.

Native relationship evidence

Every exact file and test below is linked only from the concept that introduces it.

Introduced tests

Every collected test enters the hierarchy at exactly one concept.

No tests are introduced at this concept. Its intent tests are introduced by other concepts.

Introduced code

Every collected source range enters the hierarchy at exactly one concept.

1 file ranked by introduced lines: 70 introduced LOC across 9 ranges. Expand a file to inspect source; the > gutter marks introduced lines.

src/vs/editor/common/core/cursorColumns.ts 70 introduced LOC · 9 ranges

Open complete file

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);
34 return visibleColumn + 1;
35 }
37 > /**
38 > * Returns a visible column from a column.
39 > * @see {@link CursorColumns}
40 > */
41 > public static visibleColumnFromColumn(lineContent: string, column: number, tabSize: number): number {
42 const textLen = Math.min(column - 1, lineContent.length);
43 const text = lineContent.substring(0, textLen);
54 return result;
55 }
57 > /**
58 > * Returns the value to display as "Col" in the status bar.
59 > * @see {@link CursorColumns}
60 > */
61 > public static toStatusbarColumn(lineContent: string, column: number, tabSize: number): number {
62 const text = lineContent.substring(0, Math.min(column - 1, lineContent.length));
63 const iterator = new strings.CodePointIterator(text);
76 return result + 1;
77 }
79 > /**
80 > * Returns a column from a visible column.
81 > * @see {@link CursorColumns}
82 > */
83 > public static columnFromVisibleColumn(lineContent: string, visibleColumn: number, tabSize: number): number {
84 if (visibleColumn <= 0) {
85 return 1;
115 return lineContentLength + 1;
116 }
118 > /**
119 > * ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
120 > * @see {@link CursorColumns}
121 > */
122 > public static nextRenderTabStop(visibleColumn: number, tabSize: number): number {
123 return visibleColumn + tabSize - visibleColumn % tabSize;
124 }
126 > /**
127 > * ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
128 > * @see {@link CursorColumns}
129 > */
130 > public static nextIndentTabStop(visibleColumn: number, indentSize: number): number {
131 return CursorColumns.nextRenderTabStop(visibleColumn, indentSize);
132 }
134 > /**
135 > * ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
136 > * @see {@link CursorColumns}
137 > */
138 > public static prevRenderTabStop(column: number, tabSize: number): number {
139 return Math.max(0, column - 1 - (column - 1) % tabSize);
140 }
142 > /**
143 > * ATTENTION: This works with 0-based columns (as opposed to the regular 1-based columns)
144 > * @see {@link CursorColumns}
145 > */
146 > public static prevIndentTabStop(column: number, indentSize: number): number {
147 return CursorColumns.prevRenderTabStop(column, indentSize);
148 }