Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolaRHristov committed Feb 2, 2025
2 parents 14dcdd8 + d487556 commit 3904b94
Show file tree
Hide file tree
Showing 176 changed files with 7,407 additions and 5,458 deletions.
Binary file modified Source/vs/base/browser/ui/codicons/codicon/codicon.ttf
Binary file not shown.
19 changes: 0 additions & 19 deletions Source/vs/base/browser/ui/dialog/dialog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export interface IDialogOptions {
readonly icon?: ThemeIcon;
readonly buttonDetails?: string[];
readonly disableCloseAction?: boolean;
readonly closeOnLinkClick?: boolean;
readonly disableDefaultAction?: boolean;
readonly buttonStyles: IButtonStyles;
readonly checkboxStyles: ICheckboxStyles;
Expand Down Expand Up @@ -212,20 +211,6 @@ export class Dialog extends Disposable {
return;
};

if (this.options.closeOnLinkClick) {
for (const el of this.messageContainer.getElementsByTagName('a')) {
this._register(addDisposableListener(el, EventType.CLICK, () => {
setTimeout(close); // HACK to ensure the link action is triggered before the dialog is closed
}));
this._register(addDisposableListener(el, EventType.KEY_DOWN, (e: KeyboardEvent) => {
const evt = new StandardKeyboardEvent(e);
if (evt.equals(KeyCode.Enter)) {
setTimeout(close); // HACK to ensure the link action is triggered before the dialog is closed
}
}));
}
}

const buttonBar = this.buttonBar = this._register(new ButtonBar(this.buttonsContainer));
const buttonMap = this.rearrangeButtons(this.buttons, this.options.cancelId);

Expand Down Expand Up @@ -339,10 +324,6 @@ export class Dialog extends Disposable {

// Focus next element (with wrapping)
if (evt.equals(KeyCode.Tab) || evt.equals(KeyCode.RightArrow)) {
if (focusedIndex === -1) {
focusedIndex = 0; // default to focus first element if none have focus
}

const newFocusedIndex = (focusedIndex + 1) % focusableElements.length;
focusableElements[newFocusedIndex].focus();
}
Expand Down
1 change: 1 addition & 0 deletions Source/vs/base/common/codiconsLibrary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,4 +586,5 @@ export const codiconsLibrary = {
python: register('python', 0xec39),
copilotLarge: register('copilot-large', 0xec3a),
copilotWarningLarge: register('copilot-warning-large', 0xec3b),
keyboardTab: register('keyboard-tab', 0xec3c),
} as const;
34 changes: 24 additions & 10 deletions Source/vs/base/common/ternarySearchTree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,17 +247,31 @@ export class UriIterator implements IKeyIterator<URI> {
throw new Error();
}
}

abstract class Undef {

static readonly Val: unique symbol = Symbol('undefined_placeholder');

static wrap<V>(value: V | undefined): V | typeof Undef.Val {
return value === undefined ? Undef.Val : value;
}

static unwrap<V>(value: V | typeof Undef.Val): V | undefined {
return value === Undef.Val ? undefined : value as V;
}
}

class TernarySearchTreeNode<K, V> {
height: number = 1;
segment!: string;
value: V | undefined;
value: V | typeof Undef.Val | undefined;
key: K | undefined;
left: TernarySearchTreeNode<K, V> | undefined;
mid: TernarySearchTreeNode<K, V> | undefined;
right: TernarySearchTreeNode<K, V> | undefined;

isEmpty(): boolean {
return !this.left && !this.mid && !this.right && !this.value;
return !this.left && !this.mid && !this.right && this.value === undefined;
}

rotateLeft() {
Expand Down Expand Up @@ -401,8 +415,8 @@ export class TernarySearchTree<K, V> {
}

// set value
const oldElement = node.value;
node.value = element;
const oldElement = Undef.unwrap(node.value);
node.value = Undef.wrap(element);
node.key = key;

// balance
Expand Down Expand Up @@ -462,7 +476,7 @@ export class TernarySearchTree<K, V> {
}

get(key: K): V | undefined {
return this._getNode(key)?.value;
return Undef.unwrap(this._getNode(key)?.value);
}

private _getNode(key: K) {
Expand Down Expand Up @@ -644,13 +658,13 @@ export class TernarySearchTree<K, V> {
} else if (iter.hasNext()) {
// mid
iter.next();
candidate = node.value || candidate;
candidate = Undef.unwrap(node.value) || candidate;
node = node.mid;
} else {
break;
}
}
return node && node.value || candidate;
return node && Undef.unwrap(node.value) || candidate;
}

findSuperstr(key: K): IterableIterator<[K, V]> | undefined {
Expand Down Expand Up @@ -678,7 +692,7 @@ export class TernarySearchTree<K, V> {
// collect
if (!node.mid) {
if (allowValue) {
return node.value;
return Undef.unwrap(node.value);
} else {
return undefined;
}
Expand Down Expand Up @@ -718,8 +732,8 @@ export class TernarySearchTree<K, V> {
if (node.left) {
this._dfsEntries(node.left, bucket);
}
if (node.value) {
bucket.push([node.key!, node.value]);
if (node.value !== undefined) {
bucket.push([node.key!, Undef.unwrap(node.value)!]);
}
if (node.mid) {
this._dfsEntries(node.mid, bucket);
Expand Down
8 changes: 3 additions & 5 deletions Source/vs/editor/browser/gpu/fullFileRenderStrategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { ViewLineOptions } from '../../viewParts/viewLines/viewLineOptions.
import type { ITextureAtlasPageGlyph } from '../atlas/atlas.js';
import { createContentSegmenter, type IContentSegmenter } from '../contentSegmenter.js';
import { fullFileRenderStrategyWgsl } from './fullFileRenderStrategy.wgsl.js';
import { BindingId, type IGpuRenderStrategyUpdateResult } from '../gpu.js';
import { BindingId } from '../gpu.js';
import { GPULifecycle } from '../gpuDisposable.js';
import { quadVertices } from '../gpuUtils.js';
import { GlyphRasterizer } from '../raster/glyphRasterizer.js';
Expand Down Expand Up @@ -232,7 +232,7 @@ export class FullFileRenderStrategy extends BaseRenderStrategy {
this._finalRenderedLine = 0;
}

update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult {
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number {
// IMPORTANT: This is a hot function. Variables are pre-allocated and shared within the
// loop. This is done so we don't need to trust the JIT compiler to do this optimization to
// avoid potential additional blocking time in garbage collector which is a common cause of
Expand Down Expand Up @@ -501,9 +501,7 @@ export class FullFileRenderStrategy extends BaseRenderStrategy {

this._visibleObjectCount = visibleObjectCount;

return {
localContentWidth: absoluteOffsetX
};
return visibleObjectCount;
}

draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void {
Expand Down
6 changes: 1 addition & 5 deletions Source/vs/editor/browser/gpu/gpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ export interface IGpuRenderStrategy extends IDisposable {
* Resets the render strategy, clearing all data and setting up for a new frame.
*/
reset(): void;
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult;
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number;
draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void;
}

export interface IGpuRenderStrategyUpdateResult {
localContentWidth: number;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ViewEventHandler } from '../../../common/viewEventHandler.js';
import type { ViewportData } from '../../../common/viewLayout/viewLinesViewportData.js';
import type { ViewContext } from '../../../common/viewModel/viewContext.js';
import type { ViewLineOptions } from '../../viewParts/viewLines/viewLineOptions.js';
import type { IGpuRenderStrategy, IGpuRenderStrategyUpdateResult } from '../gpu.js';
import type { IGpuRenderStrategy } from '../gpu.js';
import { GlyphRasterizer } from '../raster/glyphRasterizer.js';
import type { ViewGpuContext } from '../viewGpuContext.js';

Expand All @@ -31,6 +31,6 @@ export abstract class BaseRenderStrategy extends ViewEventHandler implements IGp
}

abstract reset(): void;
abstract update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult;
abstract update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number;
abstract draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { ViewContext } from '../../../common/viewModel/viewContext.js';
import type { ViewLineOptions } from '../../viewParts/viewLines/viewLineOptions.js';
import type { ITextureAtlasPageGlyph } from '../atlas/atlas.js';
import { createContentSegmenter, type IContentSegmenter } from '../contentSegmenter.js';
import { BindingId, type IGpuRenderStrategyUpdateResult } from '../gpu.js';
import { BindingId } from '../gpu.js';
import { GPULifecycle } from '../gpuDisposable.js';
import { quadVertices } from '../gpuUtils.js';
import { GlyphRasterizer } from '../raster/glyphRasterizer.js';
Expand Down Expand Up @@ -184,7 +184,7 @@ export class ViewportRenderStrategy extends BaseRenderStrategy {
}
}

update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): IGpuRenderStrategyUpdateResult {
update(viewportData: ViewportData, viewLineOptions: ViewLineOptions): number {
// IMPORTANT: This is a hot function. Variables are pre-allocated and shared within the
// loop. This is done so we don't need to trust the JIT compiler to do this optimization to
// avoid potential additional blocking time in garbage collector which is a common cause of
Expand Down Expand Up @@ -394,9 +394,8 @@ export class ViewportRenderStrategy extends BaseRenderStrategy {
this._activeDoubleBufferIndex = this._activeDoubleBufferIndex ? 0 : 1;

this._visibleObjectCount = visibleObjectCount;
return {
localContentWidth: absoluteOffsetX
};

return visibleObjectCount;
}

draw(pass: GPURenderPassEncoder, viewportData: ViewportData): void {
Expand Down
2 changes: 0 additions & 2 deletions Source/vs/editor/browser/gpu/viewGpuContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export class ViewGpuContext extends Disposable {
readonly maxGpuCols = ViewportRenderStrategy.maxSupportedColumns;

readonly canvas: FastDomNode<HTMLCanvasElement>;
readonly scrollWidthElement: FastDomNode<HTMLElement>;
readonly ctx: GPUCanvasContext;

static device: Promise<GPUDevice>;
Expand Down Expand Up @@ -88,7 +87,6 @@ export class ViewGpuContext extends Disposable {

this.canvas = createFastDomNode(document.createElement('canvas'));
this.canvas.setClassName('editorCanvas');
this.scrollWidthElement = createFastDomNode(document.createElement('div'));

// Adjust the canvas size to avoid drawing under the scroll bar
this._register(Event.runAndSubscribe(configurationService.onDidChangeConfiguration, e => {
Expand Down
16 changes: 12 additions & 4 deletions Source/vs/editor/browser/rect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ export class Rect {
}

public static hull(rects: Rect[]): Rect {
let left = Number.MAX_VALUE;
let top = Number.MAX_VALUE;
let right = Number.MIN_VALUE;
let bottom = Number.MIN_VALUE;
let left = Number.MAX_SAFE_INTEGER;
let top = Number.MAX_SAFE_INTEGER;
let right = Number.MIN_SAFE_INTEGER;
let bottom = Number.MIN_SAFE_INTEGER;

for (const rect of rects) {
left = Math.min(left, rect.left);
Expand Down Expand Up @@ -138,7 +138,15 @@ export class Rect {
return new Rect(this.left - delta, this.top, this.right - delta, this.bottom);
}

moveRight(delta: number): Rect {
return new Rect(this.left + delta, this.top, this.right + delta, this.bottom);
}

moveUp(delta: number): Rect {
return new Rect(this.left, this.top - delta, this.right, this.bottom - delta);
}

moveDown(delta: number): Rect {
return new Rect(this.left, this.top + delta, this.right, this.bottom + delta);
}
}
2 changes: 1 addition & 1 deletion Source/vs/editor/browser/services/bulkEditService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class ResourceTextEdit extends ResourceEdit implements IWorkspaceTextEdit

constructor(
readonly resource: URI,
readonly textEdit: TextEdit & { insertAsSnippet?: boolean },
readonly textEdit: TextEdit & { insertAsSnippet?: boolean; keepWhitespace?: boolean },
readonly versionId: number | undefined = undefined,
metadata?: WorkspaceEditMetadata,
) {
Expand Down
21 changes: 13 additions & 8 deletions Source/vs/editor/browser/view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import { ViewCursors } from './viewParts/viewCursors/viewCursors.js';
import { ViewZones } from './viewParts/viewZones/viewZones.js';
import { WhitespaceOverlay } from './viewParts/whitespace/whitespace.js';
import { IEditorConfiguration } from '../common/config/editorConfiguration.js';
import { EditorOption } from '../common/config/editorOptions.js';
import { EditorOption, IComputedEditorOptions } from '../common/config/editorOptions.js';
import { Position } from '../common/core/position.js';
import { Range } from '../common/core/range.js';
import { Selection } from '../common/core/selection.js';
Expand Down Expand Up @@ -148,7 +148,7 @@ export class View extends ViewEventHandler {
// Keyboard handler
this._experimentalEditContextEnabled = this._context.configuration.options.get(EditorOption.experimentalEditContextEnabled);
this._accessibilitySupport = this._context.configuration.options.get(EditorOption.accessibilitySupport);
this._editContext = this._instantiateEditContext(this._experimentalEditContextEnabled, this._accessibilitySupport);
this._editContext = this._instantiateEditContext();

this._viewParts.push(this._editContext);

Expand Down Expand Up @@ -256,7 +256,6 @@ export class View extends ViewEventHandler {
this._overflowGuardContainer.appendChild(this._scrollbar.getDomNode());
if (this._viewGpuContext) {
this._overflowGuardContainer.appendChild(this._viewGpuContext.canvas);
this._linesContent.appendChild(this._viewGpuContext.scrollWidthElement);
}
this._overflowGuardContainer.appendChild(scrollDecoration.getDomNode());
this._overflowGuardContainer.appendChild(this._overlayWidgets.getDomNode());
Expand All @@ -278,10 +277,9 @@ export class View extends ViewEventHandler {
this._pointerHandler = this._register(new PointerHandler(this._context, this._viewController, this._createPointerHandlerHelper()));
}

private _instantiateEditContext(experimentalEditContextEnabled: boolean, accessibilitySupport: AccessibilitySupport): AbstractEditContext {
const domNode = dom.getWindow(this._overflowGuardContainer.domNode);
const isEditContextSupported = EditContext.supported(domNode);
if (experimentalEditContextEnabled && isEditContextSupported && accessibilitySupport !== AccessibilitySupport.Enabled) {
private _instantiateEditContext(): AbstractEditContext {
const usingExperimentalEditContext = useExperimentalEditContext(dom.getWindow(this._overflowGuardContainer.domNode), this._context.configuration.options);
if (usingExperimentalEditContext) {
return this._instantiationService.createInstance(NativeEditContext, this._ownerID, this._context, this._overflowGuardContainer, this._viewController, this._createTextAreaHandlerHelper());
} else {
return this._instantiationService.createInstance(TextAreaEditContext, this._context, this._overflowGuardContainer, this._viewController, this._createTextAreaHandlerHelper());
Expand All @@ -299,7 +297,7 @@ export class View extends ViewEventHandler {
const isEditContextFocused = this._editContext.isFocused();
const indexOfEditContext = this._viewParts.indexOf(this._editContext);
this._editContext.dispose();
this._editContext = this._instantiateEditContext(experimentalEditContextEnabled, accessibilitySupport);
this._editContext = this._instantiateEditContext();
if (isEditContextFocused) {
this._editContext.focus();
}
Expand Down Expand Up @@ -853,3 +851,10 @@ class EditorRenderingCoordinator {
}
}
}

export function useExperimentalEditContext(activeWindow: CodeWindow, options: IComputedEditorOptions): boolean {
const isEditContextSupported = EditContext.supported(activeWindow);
const experimentalEditContextEnabled = options.get(EditorOption.experimentalEditContextEnabled);
const accessibilitySupport = options.get(EditorOption.accessibilitySupport);
return experimentalEditContextEnabled && isEditContextSupported && accessibilitySupport !== AccessibilitySupport.Enabled;
}
11 changes: 2 additions & 9 deletions Source/vs/editor/browser/viewParts/viewLinesGpu/viewLinesGpu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
private _initViewportData?: ViewportData[];
private _lastViewportData?: ViewportData;
private _lastViewLineOptions?: ViewLineOptions;
private _maxLocalContentWidthSoFar = 0;

private _device!: GPUDevice;
private _renderPassDescriptor!: GPURenderPassDescriptor;
Expand Down Expand Up @@ -430,6 +429,7 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {
override onCursorStateChanged(e: viewEvents.ViewCursorStateChangedEvent): boolean { return true; }
override onDecorationsChanged(e: viewEvents.ViewDecorationsChangedEvent): boolean { return true; }
override onFlushed(e: viewEvents.ViewFlushedEvent): boolean { return true; }

override onLinesChanged(e: viewEvents.ViewLinesChangedEvent): boolean { return true; }
override onLinesDeleted(e: viewEvents.ViewLinesDeletedEvent): boolean { return true; }
override onLinesInserted(e: viewEvents.ViewLinesInsertedEvent): boolean { return true; }
Expand Down Expand Up @@ -473,14 +473,7 @@ export class ViewLinesGpu extends ViewPart implements IViewLines {

const options = new ViewLineOptions(this._context.configuration, this._context.theme.type);

const { localContentWidth } = this._renderStrategy.value!.update(viewportData, options);

// Track the largest local content width so far in this session and use it as the scroll
// width. This is how the DOM renderer works as well, so you may not be able to scroll to
// the right in a file with long lines until you scroll down.
this._maxLocalContentWidthSoFar = Math.max(this._maxLocalContentWidthSoFar, localContentWidth / this._viewGpuContext.devicePixelRatio.get());
this._context.viewModel.viewLayout.setMaxLineWidth(this._maxLocalContentWidthSoFar);
this._viewGpuContext.scrollWidthElement.setWidth(this._context.viewLayout.getScrollWidth());
this._renderStrategy.value!.update(viewportData, options);

this._updateAtlasStorageBufferAndTexture();

Expand Down
Loading

0 comments on commit 3904b94

Please sign in to comment.