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 #401

Merged
merged 6 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
11 changes: 10 additions & 1 deletion src/vs/base/common/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,14 @@ export interface SerializedError {
readonly message: string;
readonly stack: string;
readonly noTelemetry: boolean;
readonly code?: string;
readonly cause?: SerializedError;
}

type ErrorWithCode = Error & {
code: string | undefined;
};

export function transformErrorForSerialization(error: Error): SerializedError;
export function transformErrorForSerialization(error: any): any;
export function transformErrorForSerialization(error: any): any {
Expand All @@ -141,7 +146,8 @@ export function transformErrorForSerialization(error: any): any {
message,
stack,
noTelemetry: ErrorNoTelemetry.isErrorNoTelemetry(error),
cause: cause ? transformErrorForSerialization(cause) : undefined
cause: cause ? transformErrorForSerialization(cause) : undefined,
code: (<ErrorWithCode>error).code
};
}

Expand All @@ -159,6 +165,9 @@ export function transformErrorFromSerialization(data: SerializedError): Error {
}
error.message = data.message;
error.stack = data.stack;
if (data.code) {
(<ErrorWithCode>error).code = data.code;
}
if (data.cause) {
error.cause = transformErrorFromSerialization(data.cause);
}
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/common/languages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2107,7 +2107,7 @@ export interface CodeLens {

export interface CodeLensList {
lenses: CodeLens[];
dispose(): void;
dispose?(): void;
}

export interface CodeLensProvider {
Expand Down
10 changes: 5 additions & 5 deletions src/vs/editor/common/languages/languageConfigurationRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { Emitter, Event } from '../../../base/common/event.js';
import { Disposable, IDisposable, toDisposable } from '../../../base/common/lifecycle.js';
import { Disposable, IDisposable, markAsSingleton, toDisposable } from '../../../base/common/lifecycle.js';
import * as strings from '../../../base/common/strings.js';
import { ITextModel } from '../model.js';
import { DEFAULT_WORD_REGEXP, ensureValidWordDefinition } from '../core/wordHelper.js';
Expand Down Expand Up @@ -202,15 +202,15 @@ class ComposedLanguageConfiguration {
);
this._entries.push(entry);
this._resolved = null;
return toDisposable(() => {
return markAsSingleton(toDisposable(() => {
for (let i = 0; i < this._entries.length; i++) {
if (this._entries[i] === entry) {
this._entries.splice(i, 1);
this._resolved = null;
break;
}
}
});
}));
}

public getResolvedConfiguration(): ResolvedLanguageConfiguration | null {
Expand Down Expand Up @@ -332,10 +332,10 @@ export class LanguageConfigurationRegistry extends Disposable {
const disposable = entries.register(configuration, priority);
this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageId));

return toDisposable(() => {
return markAsSingleton(toDisposable(() => {
disposable.dispose();
this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageId));
});
}));
}

public getLanguageConfiguration(languageId: string): ResolvedLanguageConfiguration | null {
Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/contrib/codelens/browser/codeLensCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ export class CodeLensCache implements ICodeLensCache {
};
});
const copyModel = new CodeLensModel();
copyModel.add({ lenses: copyItems, dispose: () => { } }, this._fakeProvider);
copyModel.add({ lenses: copyItems }, this._fakeProvider);

const item = new CacheItem(model.getLineCount(), copyModel);
this._cache.set(model.uri.toString(), item);
Expand Down
13 changes: 8 additions & 5 deletions src/vs/editor/contrib/codelens/browser/codelens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { CancellationToken } from '../../../../base/common/cancellation.js';
import { illegalArgument, onUnexpectedExternalError } from '../../../../base/common/errors.js';
import { DisposableStore } from '../../../../base/common/lifecycle.js';
import { DisposableStore, isDisposable } from '../../../../base/common/lifecycle.js';
import { assertType } from '../../../../base/common/types.js';
import { URI } from '../../../../base/common/uri.js';
import { ITextModel } from '../../../common/model.js';
Expand All @@ -24,18 +24,21 @@ export class CodeLensModel {

lenses: CodeLensItem[] = [];

private readonly _disposables = new DisposableStore();
private _store: DisposableStore | undefined;

dispose(): void {
this._disposables.dispose();
this._store?.dispose();
}

get isDisposed(): boolean {
return this._disposables.isDisposed;
return this._store?.isDisposed ?? false;
}

add(list: CodeLensList, provider: CodeLensProvider): void {
this._disposables.add(list);
if (isDisposable(list)) {
this._store ??= new DisposableStore();
this._store.add(list);
}
for (const symbol of list.lenses) {
this.lenses.push({ symbol, provider });
}
Expand Down
3 changes: 2 additions & 1 deletion src/vs/editor/contrib/hover/browser/contentHoverRendered.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ class RenderedContentHoverParts extends Disposable {
...hoverContext
};
const disposables = new DisposableStore();
disposables.add(statusBar);
for (const participant of participants) {
const renderedHoverParts = this._renderHoverPartsForParticipant(hoverParts, participant, hoverRenderingContext);
disposables.add(renderedHoverParts);
Expand All @@ -294,7 +295,7 @@ class RenderedContentHoverParts extends Disposable {
actions: renderedStatusBar.actions,
});
}
return toDisposable(() => { disposables.dispose(); });
return disposables;
}

private _renderHoverPartsForParticipant(hoverParts: IHoverPart[], participant: IEditorHoverParticipant<IHoverPart>, hoverRenderingContext: IEditorHoverRenderContext): IRenderedHoverParts<IHoverPart> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,8 @@ export class InlineEditsGutterIndicator extends Disposable {

const layout = this._editorObs.layoutInfo.read(reader);

const fullViewPort = Rect.fromLeftTopRightBottom(0, 0, layout.width, layout.height);
const bottomPadding = 1;
const fullViewPort = Rect.fromLeftTopRightBottom(0, 0, layout.width, layout.height - bottomPadding);
const viewPortWithStickyScroll = fullViewPort.withTop(this._stickyScrollHeight.read(reader));

const targetVertRange = s.lineOffsetRange.read(reader);
Expand Down
32 changes: 19 additions & 13 deletions src/vs/editor/contrib/links/browser/getLinks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export class Link implements ILink {

export class LinksList {

static readonly Empty = new LinksList([]);

readonly links: Link[];

private readonly _disposables = new DisposableStore();
Expand Down Expand Up @@ -137,27 +139,31 @@ export class LinksList {

}

export function getLinks(providers: LanguageFeatureRegistry<LinkProvider>, model: ITextModel, token: CancellationToken): Promise<LinksList> {

export async function getLinks(providers: LanguageFeatureRegistry<LinkProvider>, model: ITextModel, token: CancellationToken): Promise<LinksList> {
const lists: [ILinksList, LinkProvider][] = [];

// ask all providers for links in parallel
const promises = providers.ordered(model).reverse().map((provider, i) => {
return Promise.resolve(provider.provideLinks(model, token)).then(result => {
const promises = providers.ordered(model).reverse().map(async (provider, i) => {
try {
const result = await provider.provideLinks(model, token);
if (result) {
lists[i] = [result, provider];
}
}, onUnexpectedExternalError);
});

return Promise.all(promises).then(() => {
const result = new LinksList(coalesce(lists));
if (!token.isCancellationRequested) {
return result;
} catch (err) {
onUnexpectedExternalError(err);
}
result.dispose();
return new LinksList([]);
});

await Promise.all(promises);

let res = new LinksList(coalesce(lists));

if (token.isCancellationRequested) {
res.dispose();
res = LinksList.Empty;
}

return res;
}


Expand Down
2 changes: 1 addition & 1 deletion src/vs/monaco.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8060,7 +8060,7 @@ declare namespace monaco.languages {

export interface CodeLensList {
lenses: CodeLens[];
dispose(): void;
dispose?(): void;
}

export interface CodeLensProvider {
Expand Down
10 changes: 5 additions & 5 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import { IAction, SubmenuAction } from '../../../base/common/actions.js';
import { Event, MicrotaskEmitter } from '../../../base/common/event.js';
import { DisposableStore, dispose, IDisposable, toDisposable } from '../../../base/common/lifecycle.js';
import { DisposableStore, dispose, IDisposable, markAsSingleton, toDisposable } from '../../../base/common/lifecycle.js';
import { LinkedList } from '../../../base/common/linkedList.js';
import { ThemeIcon } from '../../../base/common/themables.js';
import { ICommandAction, ICommandActionTitle, Icon, ILocalizedString } from '../../action/common/action.js';
Expand Down Expand Up @@ -397,11 +397,11 @@ export const MenuRegistry: IMenuRegistry = new class implements IMenuRegistry {
this._commands.set(command.id, command);
this._onDidChangeMenu.fire(MenuRegistryChangeEvent.for(MenuId.CommandPalette));

return toDisposable(() => {
return markAsSingleton(toDisposable(() => {
if (this._commands.delete(command.id)) {
this._onDidChangeMenu.fire(MenuRegistryChangeEvent.for(MenuId.CommandPalette));
}
});
}));
}

getCommand(id: string): ICommandAction | undefined {
Expand All @@ -422,10 +422,10 @@ export const MenuRegistry: IMenuRegistry = new class implements IMenuRegistry {
}
const rm = list.push(item);
this._onDidChangeMenu.fire(MenuRegistryChangeEvent.for(id));
return toDisposable(() => {
return markAsSingleton(toDisposable(() => {
rm();
this._onDidChangeMenu.fire(MenuRegistryChangeEvent.for(id));
});
}));
}

appendMenuItems(items: Iterable<{ id: MenuId; item: IMenuItem | ISubmenuItem }>): IDisposable {
Expand Down
4 changes: 2 additions & 2 deletions src/vs/platform/commands/common/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import { Emitter, Event } from '../../../base/common/event.js';
import { Iterable } from '../../../base/common/iterator.js';
import { IJSONSchema } from '../../../base/common/jsonSchema.js';
import { IDisposable, toDisposable } from '../../../base/common/lifecycle.js';
import { IDisposable, markAsSingleton, toDisposable } from '../../../base/common/lifecycle.js';
import { LinkedList } from '../../../base/common/linkedList.js';
import { TypeConstraint, validateConstraints } from '../../../base/common/types.js';
import { ILocalizedString } from '../../action/common/action.js';
Expand Down Expand Up @@ -121,7 +121,7 @@ export const CommandsRegistry: ICommandRegistry = new class implements ICommandR
// tell the world about this command
this._onDidRegisterCommand.fire(id);

return ret;
return markAsSingleton(ret);
}

registerCommandAlias(oldId: string, newId: string): IDisposable {
Expand Down
Loading
Loading