Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] main from microsoft:main #403

Merged
merged 14 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/lib/stylelint/vscode-known-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@
"--vscode-inlineEdit-originalBackground",
"--vscode-inlineEdit-originalChangedLineBackground",
"--vscode-inlineEdit-originalChangedTextBackground",
"--vscode-inlineEdit-acceptedBackground",
"--vscode-input-background",
"--vscode-input-border",
"--vscode-input-foreground",
Expand Down
4 changes: 4 additions & 0 deletions extensions/git/src/historyProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
id: ref.substring('HEAD -> '.length),
name: ref.substring('HEAD -> refs/heads/'.length),
revision: commit.hash,
category: l10n.t('branches'),
icon: new ThemeIcon('target')
});
break;
Expand All @@ -377,6 +378,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
id: ref,
name: ref.substring('refs/heads/'.length),
revision: commit.hash,
category: l10n.t('branches'),
icon: new ThemeIcon('git-branch')
});
break;
Expand All @@ -385,6 +387,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
id: ref,
name: ref.substring('refs/remotes/'.length),
revision: commit.hash,
category: l10n.t('remote branches'),
icon: new ThemeIcon('cloud')
});
break;
Expand All @@ -393,6 +396,7 @@ export class GitHistoryProvider implements SourceControlHistoryProvider, FileDec
id: ref.substring('tag: '.length),
name: ref.substring('tag: refs/tags/'.length),
revision: commit.hash,
category: l10n.t('tags'),
icon: new ThemeIcon('tag')
});
break;
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "code-oss-dev",
"version": "1.97.0",
"distro": "baf3347105f6082ae1df942fd1c052cd06f7a7f0",
"distro": "d631a7e71cfab757e241fd75ecb1594c6b427920",
"author": {
"name": "Microsoft Corporation"
},
Expand Down Expand Up @@ -212,7 +212,7 @@
"ts-node": "^10.9.1",
"tsec": "0.2.7",
"tslib": "^2.6.3",
"typescript": "^5.8.0-dev.20241217",
"typescript": "^5.8.0-dev.20250110",
"typescript-eslint": "^8.8.0",
"util": "^0.12.4",
"webpack": "^5.94.0",
Expand Down
38 changes: 34 additions & 4 deletions src/vs/base/browser/ui/list/listView.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { DataTransfers, IDragAndDropData } from '../../dnd.js';
import { $, addDisposableListener, animate, Dimension, getContentHeight, getContentWidth, getDocument, getTopLeftOffset, getWindow, isAncestor, isHTMLElement, isSVGElement, scheduleAtNextAnimationFrame } from '../../dom.js';
import { $, addDisposableListener, animate, Dimension, getActiveElement, getContentHeight, getContentWidth, getDocument, getTopLeftOffset, getWindow, isAncestor, isHTMLElement, isSVGElement, scheduleAtNextAnimationFrame } from '../../dom.js';
import { DomEmitter } from '../../event.js';
import { IMouseWheelEvent } from '../../mouseEvent.js';
import { EventType as TouchEventType, Gesture, GestureEvent } from '../../touch.js';
Expand Down Expand Up @@ -324,6 +324,7 @@ export class ListView<T> implements IListView<T> {
private onDragLeaveTimeout: IDisposable = Disposable.None;
private currentSelectionDisposable: IDisposable = Disposable.None;
private currentSelectionBounds: IRange | undefined;
private activeElement: HTMLElement | undefined;

private readonly disposables: DisposableStore = new DisposableStore();

Expand Down Expand Up @@ -439,9 +440,13 @@ export class ListView<T> implements IListView<T> {
this.scrollableElement.onScroll(this.onScroll, this, this.disposables);
this.disposables.add(addDisposableListener(this.rowsContainer, TouchEventType.Change, e => this.onTouchChange(e as GestureEvent)));

// Prevent the monaco-scrollable-element from scrolling
// https://github.com/microsoft/vscode/issues/44181
this.disposables.add(addDisposableListener(this.scrollableElement.getDomNode(), 'scroll', e => (e.target as HTMLElement).scrollTop = 0));
this.disposables.add(addDisposableListener(this.scrollableElement.getDomNode(), 'scroll', e => {
// Make sure the active element is scrolled into view
const element = (e.target as HTMLElement);
const scrollValue = element.scrollTop;
element.scrollTop = 0;
this.setScrollTop(this.scrollTop + scrollValue);
}));

this.disposables.add(addDisposableListener(this.domNode, 'dragover', e => this.onDragOver(this.toDragEvent(e))));
this.disposables.add(addDisposableListener(this.domNode, 'drop', e => this.onDrop(this.toDragEvent(e))));
Expand All @@ -460,6 +465,31 @@ export class ListView<T> implements IListView<T> {
this.dnd = options.dnd ?? this.disposables.add(DefaultOptions.dnd);

this.layout(options.initialSize?.height, options.initialSize?.width);
this._setupFocusObserver(container);
}

private _setupFocusObserver(container: HTMLElement): void {
this.disposables.add(addDisposableListener(container, 'focus', () => {
const element = getActiveElement() as HTMLElement | null;
if (this.activeElement !== element && element !== null) {
this.activeElement = element;
this._scrollToActiveElement(this.activeElement, container);
}
}, true));
}

private _scrollToActiveElement(element: HTMLElement, container: HTMLElement) {
// The scroll event on the list only fires when scrolling down.
// If the active element is above the viewport, we need to scroll up.
const containerRect = container.getBoundingClientRect();
const elementRect = element.getBoundingClientRect();

const topOffset = elementRect.top - containerRect.top;

if (topOffset < 0) {
// Scroll up
this.setScrollTop(this.scrollTop + topOffset);
}
}

updateOptions(options: IListViewOptionsUpdate) {
Expand Down
10 changes: 5 additions & 5 deletions src/vs/base/common/color.ts
Original file line number Diff line number Diff line change
Expand Up @@ -535,17 +535,17 @@ export class Color {
return this._toString;
}

private _toNumber24Bit?: number;
toNumber24Bit(): number {
if (!this._toNumber24Bit) {
this._toNumber24Bit = (
private _toNumber32Bit?: number;
toNumber32Bit(): number {
if (!this._toNumber32Bit) {
this._toNumber32Bit = (
this.rgba.r /* */ << 24 |
this.rgba.g /* */ << 16 |
this.rgba.b /* */ << 8 |
this.rgba.a * 0xFF << 0
) >>> 0;
}
return this._toNumber24Bit;
return this._toNumber32Bit;
}

static getLighterColor(of: Color, relative: Color, factor?: number): Color {
Expand Down
60 changes: 30 additions & 30 deletions src/vs/base/test/common/color.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,40 +118,40 @@ suite('Color', () => {
});
});

suite('toNumber24Bit', () => {
suite('toNumber32Bit', () => {
test('alpha channel', () => {
assert.deepStrictEqual(Color.fromHex('#00000000').toNumber24Bit(), 0x00000000);
assert.deepStrictEqual(Color.fromHex('#00000080').toNumber24Bit(), 0x00000080);
assert.deepStrictEqual(Color.fromHex('#000000FF').toNumber24Bit(), 0x000000FF);
assert.deepStrictEqual(Color.fromHex('#00000000').toNumber32Bit(), 0x00000000);
assert.deepStrictEqual(Color.fromHex('#00000080').toNumber32Bit(), 0x00000080);
assert.deepStrictEqual(Color.fromHex('#000000FF').toNumber32Bit(), 0x000000FF);
});

test('opaque', () => {
assert.deepStrictEqual(Color.fromHex('#000000').toNumber24Bit(), 0x000000FF);
assert.deepStrictEqual(Color.fromHex('#FFFFFF').toNumber24Bit(), 0xFFFFFFFF);
assert.deepStrictEqual(Color.fromHex('#FF0000').toNumber24Bit(), 0xFF0000FF);
assert.deepStrictEqual(Color.fromHex('#00FF00').toNumber24Bit(), 0x00FF00FF);
assert.deepStrictEqual(Color.fromHex('#0000FF').toNumber24Bit(), 0x0000FFFF);
assert.deepStrictEqual(Color.fromHex('#FFFF00').toNumber24Bit(), 0xFFFF00FF);
assert.deepStrictEqual(Color.fromHex('#00FFFF').toNumber24Bit(), 0x00FFFFFF);
assert.deepStrictEqual(Color.fromHex('#FF00FF').toNumber24Bit(), 0xFF00FFFF);
assert.deepStrictEqual(Color.fromHex('#C0C0C0').toNumber24Bit(), 0xC0C0C0FF);
assert.deepStrictEqual(Color.fromHex('#808080').toNumber24Bit(), 0x808080FF);
assert.deepStrictEqual(Color.fromHex('#800000').toNumber24Bit(), 0x800000FF);
assert.deepStrictEqual(Color.fromHex('#808000').toNumber24Bit(), 0x808000FF);
assert.deepStrictEqual(Color.fromHex('#008000').toNumber24Bit(), 0x008000FF);
assert.deepStrictEqual(Color.fromHex('#800080').toNumber24Bit(), 0x800080FF);
assert.deepStrictEqual(Color.fromHex('#008080').toNumber24Bit(), 0x008080FF);
assert.deepStrictEqual(Color.fromHex('#000080').toNumber24Bit(), 0x000080FF);
assert.deepStrictEqual(Color.fromHex('#010203').toNumber24Bit(), 0x010203FF);
assert.deepStrictEqual(Color.fromHex('#040506').toNumber24Bit(), 0x040506FF);
assert.deepStrictEqual(Color.fromHex('#070809').toNumber24Bit(), 0x070809FF);
assert.deepStrictEqual(Color.fromHex('#0a0A0a').toNumber24Bit(), 0x0a0A0aFF);
assert.deepStrictEqual(Color.fromHex('#0b0B0b').toNumber24Bit(), 0x0b0B0bFF);
assert.deepStrictEqual(Color.fromHex('#0c0C0c').toNumber24Bit(), 0x0c0C0cFF);
assert.deepStrictEqual(Color.fromHex('#0d0D0d').toNumber24Bit(), 0x0d0D0dFF);
assert.deepStrictEqual(Color.fromHex('#0e0E0e').toNumber24Bit(), 0x0e0E0eFF);
assert.deepStrictEqual(Color.fromHex('#0f0F0f').toNumber24Bit(), 0x0f0F0fFF);
assert.deepStrictEqual(Color.fromHex('#a0A0a0').toNumber24Bit(), 0xa0A0a0FF);
assert.deepStrictEqual(Color.fromHex('#000000').toNumber32Bit(), 0x000000FF);
assert.deepStrictEqual(Color.fromHex('#FFFFFF').toNumber32Bit(), 0xFFFFFFFF);
assert.deepStrictEqual(Color.fromHex('#FF0000').toNumber32Bit(), 0xFF0000FF);
assert.deepStrictEqual(Color.fromHex('#00FF00').toNumber32Bit(), 0x00FF00FF);
assert.deepStrictEqual(Color.fromHex('#0000FF').toNumber32Bit(), 0x0000FFFF);
assert.deepStrictEqual(Color.fromHex('#FFFF00').toNumber32Bit(), 0xFFFF00FF);
assert.deepStrictEqual(Color.fromHex('#00FFFF').toNumber32Bit(), 0x00FFFFFF);
assert.deepStrictEqual(Color.fromHex('#FF00FF').toNumber32Bit(), 0xFF00FFFF);
assert.deepStrictEqual(Color.fromHex('#C0C0C0').toNumber32Bit(), 0xC0C0C0FF);
assert.deepStrictEqual(Color.fromHex('#808080').toNumber32Bit(), 0x808080FF);
assert.deepStrictEqual(Color.fromHex('#800000').toNumber32Bit(), 0x800000FF);
assert.deepStrictEqual(Color.fromHex('#808000').toNumber32Bit(), 0x808000FF);
assert.deepStrictEqual(Color.fromHex('#008000').toNumber32Bit(), 0x008000FF);
assert.deepStrictEqual(Color.fromHex('#800080').toNumber32Bit(), 0x800080FF);
assert.deepStrictEqual(Color.fromHex('#008080').toNumber32Bit(), 0x008080FF);
assert.deepStrictEqual(Color.fromHex('#000080').toNumber32Bit(), 0x000080FF);
assert.deepStrictEqual(Color.fromHex('#010203').toNumber32Bit(), 0x010203FF);
assert.deepStrictEqual(Color.fromHex('#040506').toNumber32Bit(), 0x040506FF);
assert.deepStrictEqual(Color.fromHex('#070809').toNumber32Bit(), 0x070809FF);
assert.deepStrictEqual(Color.fromHex('#0a0A0a').toNumber32Bit(), 0x0a0A0aFF);
assert.deepStrictEqual(Color.fromHex('#0b0B0b').toNumber32Bit(), 0x0b0B0bFF);
assert.deepStrictEqual(Color.fromHex('#0c0C0c').toNumber32Bit(), 0x0c0C0cFF);
assert.deepStrictEqual(Color.fromHex('#0d0D0d').toNumber32Bit(), 0x0d0D0dFF);
assert.deepStrictEqual(Color.fromHex('#0e0E0e').toNumber32Bit(), 0x0e0E0eFF);
assert.deepStrictEqual(Color.fromHex('#0f0F0f').toNumber32Bit(), 0x0f0F0fFF);
assert.deepStrictEqual(Color.fromHex('#a0A0a0').toNumber32Bit(), 0xa0A0a0FF);
});
});

Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/browser/gpu/atlas/atlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,4 @@ export const enum UsagePreviewColors {
Restricted = '#FF000088',
}

export type GlyphMap<T> = FourKeyMap</*chars*/string, /*tokenMetadata*/number, /*charMetadata*/number, /*rasterizerCacheKey*/string, T>;
export type GlyphMap<T> = FourKeyMap</*chars*/string, /*tokenMetadata*/number, /*decorationStyleSetId*/number, /*rasterizerCacheKey*/string, T>;
20 changes: 10 additions & 10 deletions src/vs/editor/browser/gpu/atlas/textureAtlas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export class TextureAtlas extends Disposable {
this._onDidDeleteGlyphs.fire();
}

getGlyph(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, charMetadata: number): Readonly<ITextureAtlasPageGlyph> {
getGlyph(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, decorationStyleSetId: number): Readonly<ITextureAtlasPageGlyph> {
// TODO: Encode font size and family into key
// Ignore metadata that doesn't affect the glyph
tokenMetadata &= ~(MetadataConsts.LANGUAGEID_MASK | MetadataConsts.TOKEN_TYPE_MASK | MetadataConsts.BALANCED_BRACKETS_MASK);
Expand All @@ -122,27 +122,27 @@ export class TextureAtlas extends Disposable {
}

// Try get the glyph, overflowing to a new page if necessary
return this._tryGetGlyph(this._glyphPageIndex.get(chars, tokenMetadata, charMetadata, rasterizer.cacheKey) ?? 0, rasterizer, chars, tokenMetadata, charMetadata);
return this._tryGetGlyph(this._glyphPageIndex.get(chars, tokenMetadata, decorationStyleSetId, rasterizer.cacheKey) ?? 0, rasterizer, chars, tokenMetadata, decorationStyleSetId);
}

private _tryGetGlyph(pageIndex: number, rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, charMetadata: number): Readonly<ITextureAtlasPageGlyph> {
this._glyphPageIndex.set(chars, tokenMetadata, charMetadata, rasterizer.cacheKey, pageIndex);
private _tryGetGlyph(pageIndex: number, rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, decorationStyleSetId: number): Readonly<ITextureAtlasPageGlyph> {
this._glyphPageIndex.set(chars, tokenMetadata, decorationStyleSetId, rasterizer.cacheKey, pageIndex);
return (
this._pages[pageIndex].getGlyph(rasterizer, chars, tokenMetadata, charMetadata)
this._pages[pageIndex].getGlyph(rasterizer, chars, tokenMetadata, decorationStyleSetId)
?? (pageIndex + 1 < this._pages.length
? this._tryGetGlyph(pageIndex + 1, rasterizer, chars, tokenMetadata, charMetadata)
? this._tryGetGlyph(pageIndex + 1, rasterizer, chars, tokenMetadata, decorationStyleSetId)
: undefined)
?? this._getGlyphFromNewPage(rasterizer, chars, tokenMetadata, charMetadata)
?? this._getGlyphFromNewPage(rasterizer, chars, tokenMetadata, decorationStyleSetId)
);
}

private _getGlyphFromNewPage(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, charMetadata: number): Readonly<ITextureAtlasPageGlyph> {
private _getGlyphFromNewPage(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, decorationStyleSetId: number): Readonly<ITextureAtlasPageGlyph> {
if (this._pages.length >= TextureAtlas.maximumPageCount) {
throw new Error(`Attempt to create a texture atlas page past the limit ${TextureAtlas.maximumPageCount}`);
}
this._pages.push(this._instantiationService.createInstance(TextureAtlasPage, this._pages.length, this.pageSize, this._allocatorType));
this._glyphPageIndex.set(chars, tokenMetadata, charMetadata, rasterizer.cacheKey, this._pages.length - 1);
return this._pages[this._pages.length - 1].getGlyph(rasterizer, chars, tokenMetadata, charMetadata)!;
this._glyphPageIndex.set(chars, tokenMetadata, decorationStyleSetId, rasterizer.cacheKey, this._pages.length - 1);
return this._pages[this._pages.length - 1].getGlyph(rasterizer, chars, tokenMetadata, decorationStyleSetId)!;
}

public getUsagePreview(): Promise<Blob[]> {
Expand Down
12 changes: 6 additions & 6 deletions src/vs/editor/browser/gpu/atlas/textureAtlasPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,20 @@ export class TextureAtlasPage extends Disposable implements IReadableTextureAtla
}));
}

public getGlyph(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, charMetadata: number): Readonly<ITextureAtlasPageGlyph> | undefined {
public getGlyph(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, decorationStyleSetId: number): Readonly<ITextureAtlasPageGlyph> | undefined {
// IMPORTANT: There are intentionally no intermediate variables here to aid in runtime
// optimization as it's a very hot function
return this._glyphMap.get(chars, tokenMetadata, charMetadata, rasterizer.cacheKey) ?? this._createGlyph(rasterizer, chars, tokenMetadata, charMetadata);
return this._glyphMap.get(chars, tokenMetadata, decorationStyleSetId, rasterizer.cacheKey) ?? this._createGlyph(rasterizer, chars, tokenMetadata, decorationStyleSetId);
}

private _createGlyph(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, charMetadata: number): Readonly<ITextureAtlasPageGlyph> | undefined {
private _createGlyph(rasterizer: IGlyphRasterizer, chars: string, tokenMetadata: number, decorationStyleSetId: number): Readonly<ITextureAtlasPageGlyph> | undefined {
// Ensure the glyph can fit on the page
if (this._glyphInOrderSet.size >= TextureAtlasPage.maximumGlyphCount) {
return undefined;
}

// Rasterize and allocate the glyph
const rasterizedGlyph = rasterizer.rasterizeGlyph(chars, tokenMetadata, charMetadata, this._colorMap);
const rasterizedGlyph = rasterizer.rasterizeGlyph(chars, tokenMetadata, decorationStyleSetId, this._colorMap);
const glyph = this._allocator.allocate(rasterizedGlyph);

// Ensure the glyph was allocated
Expand All @@ -89,7 +89,7 @@ export class TextureAtlasPage extends Disposable implements IReadableTextureAtla
}

// Save the glyph
this._glyphMap.set(chars, tokenMetadata, charMetadata, rasterizer.cacheKey, glyph);
this._glyphMap.set(chars, tokenMetadata, decorationStyleSetId, rasterizer.cacheKey, glyph);
this._glyphInOrderSet.add(glyph);

// Update page version and it's tracked used area
Expand All @@ -101,7 +101,7 @@ export class TextureAtlasPage extends Disposable implements IReadableTextureAtla
this._logService.trace('New glyph', {
chars,
tokenMetadata,
charMetadata,
decorationStyleSetId,
rasterizedGlyph,
glyph
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

import { $, getActiveDocument } from '../../../base/browser/dom.js';
import { Disposable, toDisposable } from '../../../base/common/lifecycle.js';
import { $, getActiveDocument } from '../../../../base/browser/dom.js';
import { Disposable, toDisposable } from '../../../../base/common/lifecycle.js';
import './media/decorationCssRuleExtractor.css';

/**
Expand Down
50 changes: 50 additions & 0 deletions src/vs/editor/browser/gpu/css/decorationStyleCache.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

export interface IDecorationStyleSet {
/**
* A 24-bit number representing `color`.
*/
color: number | undefined;
/**
* Whether the text should be rendered in bold.
*/
bold: boolean | undefined;
}

export interface IDecorationStyleCacheEntry extends IDecorationStyleSet {
/**
* A unique identifier for this set of styles.
*/
id: number;
}

export class DecorationStyleCache {

private _nextId = 1;

private readonly _cache = new Map<number, IDecorationStyleSet>();

getOrCreateEntry(color: number | undefined, bold: boolean | undefined): number {
if (color === undefined && bold === undefined) {
return 0;
}
const id = this._nextId++;
const entry = {
id,
color,
bold,
};
this._cache.set(id, entry);
return id;
}

getStyleSet(id: number): IDecorationStyleSet | undefined {
if (id === 0) {
return undefined;
}
return this._cache.get(id);
}
}
Loading
Loading