Skip to content

Commit dea356f

Browse files
committed
Merge branch 'main' into joh/swc
2 parents 8c1a962 + 339c3a9 commit dea356f

File tree

71 files changed

+377
-328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+377
-328
lines changed

extensions/git/src/repository.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ class DotGitWatcher implements IFileWatcher {
546546

547547
// Ignore changes to the "index.lock" file, and watchman fsmonitor hook (https://git-scm.com/docs/githooks#_fsmonitor_watchman) cookie files.
548548
// Watchman creates a cookie file inside the git directory whenever a query is run (https://facebook.github.io/watchman/docs/cookies.html).
549-
const filteredRootWatcher = filterEvent(rootWatcher.event, uri => !/\/\.git(\/index\.lock)?$|\/\.watchman-cookie-/.test(uri.path));
549+
const filteredRootWatcher = filterEvent(rootWatcher.event, uri => uri.scheme === 'file' && !/\/\.git(\/index\.lock)?$|\/\.watchman-cookie-/.test(uri.path));
550550
this.event = anyEvent(filteredRootWatcher, this.emitter.event);
551551

552552
repository.onDidRunGitStatus(this.updateTransientWatchers, this, this.disposables);

src/vs/editor/browser/controller/textAreaHandler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ import * as viewEvents from 'vs/editor/common/viewEvents';
3131
import { AccessibilitySupport } from 'vs/platform/accessibility/common/accessibility';
3232
import { IEditorAriaOptions } from 'vs/editor/browser/editorBrowser';
3333
import { MOUSE_CURSOR_TEXT_CSS_CLASS_NAME } from 'vs/base/browser/ui/mouseCursor/mouseCursor';
34-
import { ColorId, ITokenPresentation, TokenizationRegistry } from 'vs/editor/common/languages';
34+
import { TokenizationRegistry } from 'vs/editor/common/languages';
35+
import { ColorId, ITokenPresentation } from 'vs/editor/common/encodedTokenAttributes';
3536
import { Color } from 'vs/base/common/color';
3637

3738
export interface IVisibleRangeProvider {

src/vs/editor/browser/viewParts/minimap/minimap.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { Range } from 'vs/editor/common/core/range';
1818
import { RGBA8 } from 'vs/editor/common/core/rgba';
1919
import { ScrollType } from 'vs/editor/common/editorCommon';
2020
import { IEditorConfiguration } from 'vs/editor/common/config/editorConfiguration';
21-
import { ColorId } from 'vs/editor/common/languages';
21+
import { ColorId } from 'vs/editor/common/encodedTokenAttributes';
2222
import { MinimapCharRenderer } from 'vs/editor/browser/viewParts/minimap/minimapCharRenderer';
2323
import { Constants } from 'vs/editor/browser/viewParts/minimap/minimapCharSheet';
2424
import { MinimapTokensColorTracker } from 'vs/editor/common/viewModel/minimapTokensColorTracker';
Lines changed: 193 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,193 @@
1+
/*---------------------------------------------------------------------------------------------
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+
/**
7+
* Open ended enum at runtime
8+
*/
9+
export const enum LanguageId {
10+
Null = 0,
11+
PlainText = 1
12+
}
13+
14+
/**
15+
* A font style. Values are 2^x such that a bit mask can be used.
16+
*/
17+
export const enum FontStyle {
18+
NotSet = -1,
19+
None = 0,
20+
Italic = 1,
21+
Bold = 2,
22+
Underline = 4,
23+
Strikethrough = 8,
24+
}
25+
26+
/**
27+
* Open ended enum at runtime
28+
*/
29+
export const enum ColorId {
30+
None = 0,
31+
DefaultForeground = 1,
32+
DefaultBackground = 2
33+
}
34+
35+
/**
36+
* A standard token type.
37+
*/
38+
export const enum StandardTokenType {
39+
Other = 0,
40+
Comment = 1,
41+
String = 2,
42+
RegEx = 3
43+
}
44+
45+
/**
46+
* Helpers to manage the "collapsed" metadata of an entire StackElement stack.
47+
* The following assumptions have been made:
48+
* - languageId < 256 => needs 8 bits
49+
* - unique color count < 512 => needs 9 bits
50+
*
51+
* The binary format is:
52+
* - -------------------------------------------
53+
* 3322 2222 2222 1111 1111 1100 0000 0000
54+
* 1098 7654 3210 9876 5432 1098 7654 3210
55+
* - -------------------------------------------
56+
* xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx
57+
* bbbb bbbb ffff ffff fFFF FBTT LLLL LLLL
58+
* - -------------------------------------------
59+
* - L = LanguageId (8 bits)
60+
* - T = StandardTokenType (2 bits)
61+
* - B = Balanced bracket (1 bit)
62+
* - F = FontStyle (4 bits)
63+
* - f = foreground color (9 bits)
64+
* - b = background color (9 bits)
65+
*
66+
*/
67+
export const enum MetadataConsts {
68+
LANGUAGEID_MASK = 0b00000000000000000000000011111111,
69+
TOKEN_TYPE_MASK = 0b00000000000000000000001100000000,
70+
BALANCED_BRACKETS_MASK = 0b00000000000000000000010000000000,
71+
FONT_STYLE_MASK = 0b00000000000000000111100000000000,
72+
FOREGROUND_MASK = 0b00000000111111111000000000000000,
73+
BACKGROUND_MASK = 0b11111111000000000000000000000000,
74+
75+
ITALIC_MASK = 0b00000000000000000000100000000000,
76+
BOLD_MASK = 0b00000000000000000001000000000000,
77+
UNDERLINE_MASK = 0b00000000000000000010000000000000,
78+
STRIKETHROUGH_MASK = 0b00000000000000000100000000000000,
79+
80+
// Semantic tokens cannot set the language id, so we can
81+
// use the first 8 bits for control purposes
82+
SEMANTIC_USE_ITALIC = 0b00000000000000000000000000000001,
83+
SEMANTIC_USE_BOLD = 0b00000000000000000000000000000010,
84+
SEMANTIC_USE_UNDERLINE = 0b00000000000000000000000000000100,
85+
SEMANTIC_USE_STRIKETHROUGH = 0b00000000000000000000000000001000,
86+
SEMANTIC_USE_FOREGROUND = 0b00000000000000000000000000010000,
87+
SEMANTIC_USE_BACKGROUND = 0b00000000000000000000000000100000,
88+
89+
LANGUAGEID_OFFSET = 0,
90+
TOKEN_TYPE_OFFSET = 8,
91+
BALANCED_BRACKETS_OFFSET = 10,
92+
FONT_STYLE_OFFSET = 11,
93+
FOREGROUND_OFFSET = 15,
94+
BACKGROUND_OFFSET = 24
95+
}
96+
97+
/**
98+
*/
99+
export class TokenMetadata {
100+
101+
public static getLanguageId(metadata: number): LanguageId {
102+
return (metadata & MetadataConsts.LANGUAGEID_MASK) >>> MetadataConsts.LANGUAGEID_OFFSET;
103+
}
104+
105+
public static getTokenType(metadata: number): StandardTokenType {
106+
return (metadata & MetadataConsts.TOKEN_TYPE_MASK) >>> MetadataConsts.TOKEN_TYPE_OFFSET;
107+
}
108+
109+
public static containsBalancedBrackets(metadata: number): boolean {
110+
return (metadata & MetadataConsts.BALANCED_BRACKETS_MASK) !== 0;
111+
}
112+
113+
public static getFontStyle(metadata: number): FontStyle {
114+
return (metadata & MetadataConsts.FONT_STYLE_MASK) >>> MetadataConsts.FONT_STYLE_OFFSET;
115+
}
116+
117+
public static getForeground(metadata: number): ColorId {
118+
return (metadata & MetadataConsts.FOREGROUND_MASK) >>> MetadataConsts.FOREGROUND_OFFSET;
119+
}
120+
121+
public static getBackground(metadata: number): ColorId {
122+
return (metadata & MetadataConsts.BACKGROUND_MASK) >>> MetadataConsts.BACKGROUND_OFFSET;
123+
}
124+
125+
public static getClassNameFromMetadata(metadata: number): string {
126+
const foreground = this.getForeground(metadata);
127+
let className = 'mtk' + foreground;
128+
129+
const fontStyle = this.getFontStyle(metadata);
130+
if (fontStyle & FontStyle.Italic) {
131+
className += ' mtki';
132+
}
133+
if (fontStyle & FontStyle.Bold) {
134+
className += ' mtkb';
135+
}
136+
if (fontStyle & FontStyle.Underline) {
137+
className += ' mtku';
138+
}
139+
if (fontStyle & FontStyle.Strikethrough) {
140+
className += ' mtks';
141+
}
142+
143+
return className;
144+
}
145+
146+
public static getInlineStyleFromMetadata(metadata: number, colorMap: string[]): string {
147+
const foreground = this.getForeground(metadata);
148+
const fontStyle = this.getFontStyle(metadata);
149+
150+
let result = `color: ${colorMap[foreground]};`;
151+
if (fontStyle & FontStyle.Italic) {
152+
result += 'font-style: italic;';
153+
}
154+
if (fontStyle & FontStyle.Bold) {
155+
result += 'font-weight: bold;';
156+
}
157+
let textDecoration = '';
158+
if (fontStyle & FontStyle.Underline) {
159+
textDecoration += ' underline';
160+
}
161+
if (fontStyle & FontStyle.Strikethrough) {
162+
textDecoration += ' line-through';
163+
}
164+
if (textDecoration) {
165+
result += `text-decoration:${textDecoration};`;
166+
167+
}
168+
return result;
169+
}
170+
171+
public static getPresentationFromMetadata(metadata: number): ITokenPresentation {
172+
const foreground = this.getForeground(metadata);
173+
const fontStyle = this.getFontStyle(metadata);
174+
175+
return {
176+
foreground: foreground,
177+
italic: Boolean(fontStyle & FontStyle.Italic),
178+
bold: Boolean(fontStyle & FontStyle.Bold),
179+
underline: Boolean(fontStyle & FontStyle.Underline),
180+
strikethrough: Boolean(fontStyle & FontStyle.Strikethrough),
181+
};
182+
}
183+
}
184+
185+
/**
186+
*/
187+
export interface ITokenPresentation {
188+
foreground: ColorId;
189+
italic: boolean;
190+
bold: boolean;
191+
underline: boolean;
192+
strikethrough: boolean;
193+
}

0 commit comments

Comments
 (0)