mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 17:19:48 +01:00
Merge branch 'main' into merogge/select
This commit is contained in:
+1
-1
@@ -68,7 +68,7 @@
|
||||
"@vscode/policy-watcher": "^1.1.4",
|
||||
"@vscode/proxy-agent": "^0.13.1",
|
||||
"@vscode/ripgrep": "^1.15.0",
|
||||
"@vscode/sqlite3": "5.1.2-vscode",
|
||||
"@vscode/sqlite3": "5.1.3-vscode",
|
||||
"@vscode/sudo-prompt": "9.3.1",
|
||||
"@vscode/vscode-languagedetection": "1.0.21",
|
||||
"graceful-fs": "4.2.8",
|
||||
|
||||
@@ -1224,8 +1224,6 @@ export interface DocumentRangeFormattingEditProvider {
|
||||
|
||||
readonly displayName?: string;
|
||||
|
||||
readonly canFormatMultipleRanges: boolean;
|
||||
|
||||
/**
|
||||
* Provide formatting edits for a range in a document.
|
||||
*
|
||||
@@ -1234,6 +1232,8 @@ export interface DocumentRangeFormattingEditProvider {
|
||||
* of the range to full syntax nodes.
|
||||
*/
|
||||
provideDocumentRangeFormattingEdits(model: model.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
||||
|
||||
provideDocumentRangesFormattingEdits?(model: model.ITextModel, ranges: Range[], options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
||||
}
|
||||
/**
|
||||
* The document formatting provider interface defines the contract between extensions and
|
||||
|
||||
@@ -217,12 +217,12 @@ export async function formatDocumentRangesWithProvider(
|
||||
const allEdits: TextEdit[] = [];
|
||||
const rawEditsList: TextEdit[][] = [];
|
||||
try {
|
||||
if (provider.canFormatMultipleRanges) {
|
||||
if (typeof provider.provideDocumentRangesFormattingEdits === 'function') {
|
||||
logService.trace(`[format][provideDocumentRangeFormattingEdits] (request)`, provider.extensionId?.value, ranges);
|
||||
const result = (await provider.provideDocumentRangeFormattingEdits(
|
||||
const result = (await provider.provideDocumentRangesFormattingEdits(
|
||||
model,
|
||||
ranges[0],
|
||||
{ ...model.getFormattingOptions(), ranges },
|
||||
ranges,
|
||||
model.getFormattingOptions(),
|
||||
cts.token
|
||||
)) || [];
|
||||
logService.trace(`[format][provideDocumentRangeFormattingEdits] (response)`, provider.extensionId?.value, result);
|
||||
|
||||
@@ -83,14 +83,6 @@ export class GhostTextPart {
|
||||
}
|
||||
|
||||
export class GhostTextReplacement {
|
||||
public readonly parts: ReadonlyArray<GhostTextPart> = [
|
||||
new GhostTextPart(
|
||||
this.columnStart + this.length,
|
||||
this.newLines,
|
||||
false
|
||||
),
|
||||
];
|
||||
|
||||
constructor(
|
||||
readonly lineNumber: number,
|
||||
readonly columnStart: number,
|
||||
@@ -98,6 +90,13 @@ export class GhostTextReplacement {
|
||||
readonly newLines: readonly string[],
|
||||
public readonly additionalReservedLineCount: number = 0,
|
||||
) { }
|
||||
public readonly parts: ReadonlyArray<GhostTextPart> = [
|
||||
new GhostTextPart(
|
||||
this.columnStart + this.length,
|
||||
this.newLines,
|
||||
false
|
||||
),
|
||||
];
|
||||
|
||||
renderForScreenReader(_lineText: string): string {
|
||||
return this.newLines.join('\n');
|
||||
|
||||
@@ -78,17 +78,26 @@ export class InlineCompletionsModel extends Disposable implements GhostTextWidge
|
||||
})
|
||||
);
|
||||
|
||||
this._register(this.editor.onDidType((e) => { this.handleUserInput(); }));
|
||||
this._register(
|
||||
this.editor.onDidType((e) => {
|
||||
this.handleUserInput();
|
||||
})
|
||||
);
|
||||
|
||||
this._register(
|
||||
this.editor.onDidChangeCursorPosition((e) => {
|
||||
if (e.reason === CursorChangeReason.Explicit || this.session && !this.session.isValid) {
|
||||
if (e.reason === CursorChangeReason.Explicit ||
|
||||
this.session && !this.session.isValid) {
|
||||
this.hide();
|
||||
}
|
||||
})
|
||||
);
|
||||
|
||||
this._register(toDisposable(() => { this.disposed = true; }));
|
||||
this._register(
|
||||
toDisposable(() => {
|
||||
this.disposed = true;
|
||||
})
|
||||
);
|
||||
|
||||
this._register(
|
||||
this.editor.onDidBlurEditorWidget(() => {
|
||||
|
||||
+14
-9
@@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { compareBy, findMaxBy, numberComparator } from 'vs/base/common/arrays';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { Emitter, Event } from 'vs/base/common/event';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IActiveCodeEditor } from 'vs/editor/browser/editorBrowser';
|
||||
import { Position } from 'vs/editor/common/core/position';
|
||||
@@ -15,7 +15,6 @@ import { SnippetSession } from 'vs/editor/contrib/snippet/browser/snippetSession
|
||||
import { CompletionItem } from 'vs/editor/contrib/suggest/browser/suggest';
|
||||
import { SuggestController } from 'vs/editor/contrib/suggest/browser/suggestController';
|
||||
import { minimizeInlineCompletion, NormalizedInlineCompletion, normalizedInlineCompletionsEquals } from './inlineCompletionToGhostText';
|
||||
import { IObservable, observableValue, transaction } from 'vs/base/common/observable';
|
||||
|
||||
export interface SuggestWidgetState {
|
||||
/**
|
||||
@@ -35,11 +34,18 @@ export class SuggestWidgetInlineCompletionProvider extends Disposable {
|
||||
private isShiftKeyPressed = false;
|
||||
private _isActive = false;
|
||||
private _currentSuggestItemInfo: SuggestItemInfo | undefined = undefined;
|
||||
private readonly onDidChangeEmitter = new Emitter<void>();
|
||||
|
||||
private readonly _state = observableValue('suggestWidgetInlineCompletionProvider.state', undefined as SuggestWidgetState | undefined);
|
||||
public readonly onDidChange = this.onDidChangeEmitter.event;
|
||||
|
||||
public get state(): IObservable<SuggestWidgetState | undefined> {
|
||||
return this._state;
|
||||
/**
|
||||
* Returns undefined if the suggest widget is not active.
|
||||
*/
|
||||
get state(): SuggestWidgetState | undefined {
|
||||
if (!this._isActive) {
|
||||
return undefined;
|
||||
}
|
||||
return { selectedItem: this._currentSuggestItemInfo };
|
||||
}
|
||||
|
||||
constructor(
|
||||
@@ -81,7 +87,8 @@ export class SuggestWidgetInlineCompletionProvider extends Disposable {
|
||||
if (!normalizedSuggestItem) {
|
||||
return undefined;
|
||||
}
|
||||
const valid = rangeStartsWith(normalizedItemToPreselect.range, normalizedSuggestItem.range) &&
|
||||
const valid =
|
||||
rangeStartsWith(normalizedItemToPreselect.range, normalizedSuggestItem.range) &&
|
||||
normalizedItemToPreselect.insertText.startsWith(normalizedSuggestItem.insertText);
|
||||
return { index, valid, prefixLength: normalizedSuggestItem.insertText.length, suggestItem };
|
||||
})
|
||||
@@ -135,9 +142,7 @@ export class SuggestWidgetInlineCompletionProvider extends Disposable {
|
||||
shouldFire = true;
|
||||
}
|
||||
if (shouldFire) {
|
||||
transaction(tx => {
|
||||
this._state.set(this._isActive ? { selectedItem: this._currentSuggestItemInfo } : undefined, tx);
|
||||
});
|
||||
this.onDidChangeEmitter.fire();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,6 @@ import { BaseGhostTextWidgetModel, GhostText } from './ghostText';
|
||||
import { provideInlineCompletions, TrackedInlineCompletions, UpdateOperation } from './inlineCompletionsModel';
|
||||
import { inlineCompletionToGhostText, minimizeInlineCompletion, NormalizedInlineCompletion } from './inlineCompletionToGhostText';
|
||||
import { SuggestWidgetInlineCompletionProvider } from './suggestWidgetInlineCompletionProvider';
|
||||
import { autorun } from 'vs/base/common/observable';
|
||||
|
||||
export class SuggestWidgetPreviewModel extends BaseGhostTextWidgetModel {
|
||||
private readonly suggestionInlineCompletionSource = this._register(
|
||||
@@ -46,7 +45,7 @@ export class SuggestWidgetPreviewModel extends BaseGhostTextWidgetModel {
|
||||
) {
|
||||
super(editor);
|
||||
|
||||
this._register(autorun('update', reader => {
|
||||
this._register(this.suggestionInlineCompletionSource.onDidChange(() => {
|
||||
if (!this.editor.hasModel()) {
|
||||
// onDidChange might be called when calling setModel on the editor, before we are disposed.
|
||||
return;
|
||||
@@ -54,7 +53,7 @@ export class SuggestWidgetPreviewModel extends BaseGhostTextWidgetModel {
|
||||
|
||||
this.updateCacheSoon.schedule();
|
||||
|
||||
const suggestWidgetState = this.suggestionInlineCompletionSource.state.read(reader);
|
||||
const suggestWidgetState = this.suggestionInlineCompletionSource.state;
|
||||
if (!suggestWidgetState) {
|
||||
this.minReservedLineCount = 0;
|
||||
}
|
||||
@@ -91,7 +90,7 @@ export class SuggestWidgetPreviewModel extends BaseGhostTextWidgetModel {
|
||||
}
|
||||
|
||||
private async updateCache() {
|
||||
const state = this.suggestionInlineCompletionSource.state.get();
|
||||
const state = this.suggestionInlineCompletionSource.state;
|
||||
if (!state || !state.selectedItem) {
|
||||
return;
|
||||
}
|
||||
@@ -153,7 +152,7 @@ export class SuggestWidgetPreviewModel extends BaseGhostTextWidgetModel {
|
||||
const augmentedCompletion = minimizeInlineCompletion(model, this.cache.value?.completions[0]?.toLiveInlineCompletion());
|
||||
|
||||
const suggestWidgetState = this.suggestionInlineCompletionSource.state;
|
||||
const suggestInlineCompletion = minimizeInlineCompletion(model, suggestWidgetState?.get()?.selectedItem?.normalizedInlineCompletion);
|
||||
const suggestInlineCompletion = minimizeInlineCompletion(model, suggestWidgetState?.selectedItem?.normalizedInlineCompletion);
|
||||
|
||||
const isAugmentedCompletionValid = augmentedCompletion
|
||||
&& suggestInlineCompletion
|
||||
|
||||
Vendored
+1
-1
@@ -7212,7 +7212,6 @@ declare namespace monaco.languages {
|
||||
*/
|
||||
export interface DocumentRangeFormattingEditProvider {
|
||||
readonly displayName?: string;
|
||||
readonly canFormatMultipleRanges: boolean;
|
||||
/**
|
||||
* Provide formatting edits for a range in a document.
|
||||
*
|
||||
@@ -7221,6 +7220,7 @@ declare namespace monaco.languages {
|
||||
* of the range to full syntax nodes.
|
||||
*/
|
||||
provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
||||
provideDocumentRangesFormattingEdits?(model: editor.ITextModel, ranges: Range[], options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -32,7 +32,7 @@ import * as callh from 'vs/workbench/contrib/callHierarchy/common/callHierarchy'
|
||||
import * as search from 'vs/workbench/contrib/search/common/search';
|
||||
import * as typeh from 'vs/workbench/contrib/typeHierarchy/common/typeHierarchy';
|
||||
import { extHostNamedCustomer, IExtHostContext } from 'vs/workbench/services/extensions/common/extHostCustomers';
|
||||
import { ExtHostContext, ExtHostLanguageFeaturesShape, ICallHierarchyItemDto, ICodeActionDto, ICodeActionProviderMetadataDto, IdentifiableInlineCompletion, IdentifiableInlineCompletions, IDocumentFilterDto, IIndentationRuleDto, IInlayHintDto, ILanguageConfigurationDto, ILanguageWordDefinitionDto, ILinkDto, ILocationDto, ILocationLinkDto, IOnEnterRuleDto, IRegExpDto, ISignatureHelpProviderMetadataDto, ISuggestDataDto, ISuggestDataDtoField, ISuggestResultDtoField, ITypeHierarchyItemDto, IWorkspaceSymbolDto, MainContext, MainThreadLanguageFeaturesShape, IRangeFormattingProviderMetadataDto } from '../common/extHost.protocol';
|
||||
import { ExtHostContext, ExtHostLanguageFeaturesShape, ICallHierarchyItemDto, ICodeActionDto, ICodeActionProviderMetadataDto, IdentifiableInlineCompletion, IdentifiableInlineCompletions, IDocumentFilterDto, IIndentationRuleDto, IInlayHintDto, ILanguageConfigurationDto, ILanguageWordDefinitionDto, ILinkDto, ILocationDto, ILocationLinkDto, IOnEnterRuleDto, IRegExpDto, ISignatureHelpProviderMetadataDto, ISuggestDataDto, ISuggestDataDtoField, ISuggestResultDtoField, ITypeHierarchyItemDto, IWorkspaceSymbolDto, MainContext, MainThreadLanguageFeaturesShape } from '../common/extHost.protocol';
|
||||
|
||||
@extHostNamedCustomer(MainContext.MainThreadLanguageFeatures)
|
||||
export class MainThreadLanguageFeatures extends Disposable implements MainThreadLanguageFeaturesShape {
|
||||
@@ -401,14 +401,18 @@ export class MainThreadLanguageFeatures extends Disposable implements MainThread
|
||||
}));
|
||||
}
|
||||
|
||||
$registerRangeFormattingSupport(handle: number, selector: IDocumentFilterDto[], extensionId: ExtensionIdentifier, displayName: string, metadata: IRangeFormattingProviderMetadataDto): void {
|
||||
$registerRangeFormattingSupport(handle: number, selector: IDocumentFilterDto[], extensionId: ExtensionIdentifier, displayName: string, supportsRanges: boolean): void {
|
||||
this._registrations.set(handle, this._languageFeaturesService.documentRangeFormattingEditProvider.register(selector, <languages.DocumentRangeFormattingEditProvider>{
|
||||
extensionId,
|
||||
displayName,
|
||||
canFormatMultipleRanges: metadata.canFormatMultipleRanges,
|
||||
provideDocumentRangeFormattingEdits: (model: ITextModel, range: EditorRange, options: languages.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined> => {
|
||||
return this._proxy.$provideDocumentRangeFormattingEdits(handle, model.uri, range, options, token);
|
||||
}
|
||||
},
|
||||
provideDocumentRangesFormattingEdits: !supportsRanges
|
||||
? undefined
|
||||
: (model, ranges, options, token) => {
|
||||
return this._proxy.$provideDocumentRangesFormattingEdits(handle, model.uri, ranges, options, token);
|
||||
},
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
@@ -536,8 +536,8 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I
|
||||
registerDocumentFormattingEditProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentFormattingEditProvider): vscode.Disposable {
|
||||
return extHostLanguageFeatures.registerDocumentFormattingEditProvider(extension, checkSelector(selector), provider);
|
||||
},
|
||||
registerDocumentRangeFormattingEditProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentRangeFormattingEditProvider, metadata?: vscode.DocumentRangeFormattingEditProviderMetadata): vscode.Disposable {
|
||||
return extHostLanguageFeatures.registerDocumentRangeFormattingEditProvider(extension, checkSelector(selector), provider, metadata);
|
||||
registerDocumentRangeFormattingEditProvider(selector: vscode.DocumentSelector, provider: vscode.DocumentRangeFormattingEditProvider): vscode.Disposable {
|
||||
return extHostLanguageFeatures.registerDocumentRangeFormattingEditProvider(extension, checkSelector(selector), provider);
|
||||
},
|
||||
registerOnTypeFormattingEditProvider(selector: vscode.DocumentSelector, provider: vscode.OnTypeFormattingEditProvider, firstTriggerCharacter: string, ...moreTriggerCharacters: string[]): vscode.Disposable {
|
||||
return extHostLanguageFeatures.registerOnTypeFormattingEditProvider(extension, checkSelector(selector), provider, [firstTriggerCharacter].concat(moreTriggerCharacters));
|
||||
|
||||
@@ -356,10 +356,6 @@ export interface IDocumentFilterDto {
|
||||
notebookType?: string;
|
||||
}
|
||||
|
||||
export interface IRangeFormattingProviderMetadataDto {
|
||||
readonly canFormatMultipleRanges?: boolean;
|
||||
}
|
||||
|
||||
export interface ISignatureHelpProviderMetadataDto {
|
||||
readonly triggerCharacters: readonly string[];
|
||||
readonly retriggerCharacters: readonly string[];
|
||||
@@ -392,7 +388,7 @@ export interface MainThreadLanguageFeaturesShape extends IDisposable {
|
||||
$registerQuickFixSupport(handle: number, selector: IDocumentFilterDto[], metadata: ICodeActionProviderMetadataDto, displayName: string, supportsResolve: boolean): void;
|
||||
$registerPasteEditProvider(handle: number, selector: IDocumentFilterDto[], supportsCopy: boolean, pasteMimeTypes: readonly string[]): void;
|
||||
$registerDocumentFormattingSupport(handle: number, selector: IDocumentFilterDto[], extensionId: ExtensionIdentifier, displayName: string): void;
|
||||
$registerRangeFormattingSupport(handle: number, selector: IDocumentFilterDto[], extensionId: ExtensionIdentifier, displayName: string, metadata: IRangeFormattingProviderMetadataDto): void;
|
||||
$registerRangeFormattingSupport(handle: number, selector: IDocumentFilterDto[], extensionId: ExtensionIdentifier, displayName: string, supportRanges: boolean): void;
|
||||
$registerOnTypeFormattingSupport(handle: number, selector: IDocumentFilterDto[], autoFormatTriggerCharacters: string[], extensionId: ExtensionIdentifier): void;
|
||||
$registerNavigateTypeSupport(handle: number, supportsResolve: boolean): void;
|
||||
$registerRenameSupport(handle: number, selector: IDocumentFilterDto[], supportsResolveInitialValues: boolean): void;
|
||||
@@ -1834,6 +1830,7 @@ export interface ExtHostLanguageFeaturesShape {
|
||||
$providePasteEdits(handle: number, requestId: number, uri: UriComponents, ranges: IRange[], dataTransfer: DataTransferDTO, token: CancellationToken): Promise<IPasteEditDto | undefined>;
|
||||
$provideDocumentFormattingEdits(handle: number, resource: UriComponents, options: languages.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined>;
|
||||
$provideDocumentRangeFormattingEdits(handle: number, resource: UriComponents, range: IRange, options: languages.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined>;
|
||||
$provideDocumentRangesFormattingEdits(handle: number, resource: UriComponents, range: IRange[], options: languages.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined>;
|
||||
$provideOnTypeFormattingEdits(handle: number, resource: UriComponents, position: IPosition, ch: string, options: languages.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined>;
|
||||
$provideWorkspaceSymbols(handle: number, search: string, token: CancellationToken): Promise<IWorkspaceSymbolsDto>;
|
||||
$resolveWorkspaceSymbol(handle: number, symbol: IWorkspaceSymbolDto, token: CancellationToken): Promise<IWorkspaceSymbolDto | undefined>;
|
||||
|
||||
@@ -18,7 +18,7 @@ import { regExpLeadsToEndlessLoop, regExpFlags } from 'vs/base/common/strings';
|
||||
import { IPosition } from 'vs/editor/common/core/position';
|
||||
import { IRange, Range as EditorRange } from 'vs/editor/common/core/range';
|
||||
import { isFalsyOrEmpty, isNonEmptyArray, coalesce } from 'vs/base/common/arrays';
|
||||
import { isObject } from 'vs/base/common/types';
|
||||
import { assertType, isObject } from 'vs/base/common/types';
|
||||
import { ISelection, Selection } from 'vs/editor/common/core/selection';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
@@ -579,6 +579,18 @@ class RangeFormattingAdapter {
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async provideDocumentRangesFormattingEdits(resource: URI, ranges: IRange[], options: languages.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined> {
|
||||
assertType(typeof this._provider.provideDocumentRangesFormattingEdits === 'function', 'INVALID invocation of `provideDocumentRangesFormattingEdits`');
|
||||
|
||||
const document = this._documents.getDocument(resource);
|
||||
const _ranges = <Range[]>ranges.map(typeConvert.Range.to);
|
||||
const value = await this._provider.provideDocumentRangesFormattingEdits(document, _ranges, <any>options, token);
|
||||
if (Array.isArray(value)) {
|
||||
return value.map(typeConvert.TextEdit.from);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
class OnTypeFormattingAdapter {
|
||||
@@ -2055,13 +2067,13 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
|
||||
return this._withAdapter(handle, DocumentFormattingAdapter, adapter => adapter.provideDocumentFormattingEdits(URI.revive(resource), options, token), undefined, token);
|
||||
}
|
||||
|
||||
registerDocumentRangeFormattingEditProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.DocumentRangeFormattingEditProvider, metadata?: vscode.DocumentRangeFormattingEditProviderMetadata): vscode.Disposable {
|
||||
const canFormatMultipleRanges = metadata?.canFormatMultipleRanges ?? false;
|
||||
registerDocumentRangeFormattingEditProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.DocumentRangeFormattingEditProvider): vscode.Disposable {
|
||||
const canFormatMultipleRanges = typeof provider.provideDocumentRangesFormattingEdits === 'function';
|
||||
if (canFormatMultipleRanges) {
|
||||
checkProposedApiEnabled(extension, 'formatMultipleRanges');
|
||||
}
|
||||
const handle = this._addNewAdapter(new RangeFormattingAdapter(this._documents, provider), extension);
|
||||
this._proxy.$registerRangeFormattingSupport(handle, this._transformDocumentSelector(selector), extension.identifier, extension.displayName || extension.name, metadata ?? { canFormatMultipleRanges: false });
|
||||
this._proxy.$registerRangeFormattingSupport(handle, this._transformDocumentSelector(selector), extension.identifier, extension.displayName || extension.name, canFormatMultipleRanges);
|
||||
return this._createDisposable(handle);
|
||||
}
|
||||
|
||||
@@ -2069,6 +2081,10 @@ export class ExtHostLanguageFeatures implements extHostProtocol.ExtHostLanguageF
|
||||
return this._withAdapter(handle, RangeFormattingAdapter, adapter => adapter.provideDocumentRangeFormattingEdits(URI.revive(resource), range, options, token), undefined, token);
|
||||
}
|
||||
|
||||
$provideDocumentRangesFormattingEdits(handle: number, resource: UriComponents, ranges: IRange[], options: languages.FormattingOptions, token: CancellationToken): Promise<ISingleEditOperation[] | undefined> {
|
||||
return this._withAdapter(handle, RangeFormattingAdapter, adapter => adapter.provideDocumentRangesFormattingEdits(URI.revive(resource), ranges, options, token), undefined, token);
|
||||
}
|
||||
|
||||
registerOnTypeFormattingEditProvider(extension: IExtensionDescription, selector: vscode.DocumentSelector, provider: vscode.OnTypeFormattingEditProvider, triggerCharacters: string[]): vscode.Disposable {
|
||||
const handle = this._addNewAdapter(new OnTypeFormattingAdapter(this._documents, provider), extension);
|
||||
this._proxy.$registerOnTypeFormattingSupport(handle, this._transformDocumentSelector(selector), triggerCharacters, extension.identifier);
|
||||
|
||||
+12
-26
@@ -7,37 +7,23 @@ declare module 'vscode' {
|
||||
|
||||
// https://github.com/microsoft/vscode/issues/158776
|
||||
|
||||
/**
|
||||
* Metadata about a registered {@linkcode DocumentRangeFormattingEditProvider}.
|
||||
*/
|
||||
export interface DocumentRangeFormattingEditProviderMetadata {
|
||||
/**
|
||||
* `true` if the range formatting provider supports formatting multiple ranges at once.
|
||||
*/
|
||||
readonly canFormatMultipleRanges?: boolean;
|
||||
}
|
||||
|
||||
export interface FormattingOptions2 {
|
||||
|
||||
/**
|
||||
* The list of multiple ranges to format at once, if the provider supports it.
|
||||
*/
|
||||
// TODO@API should this all ranges or all except for the first range?
|
||||
// TODO@API needs a name that is more descriptive
|
||||
ranges?: Range[];
|
||||
|
||||
[key: string]: boolean | number | string | undefined | object;
|
||||
}
|
||||
|
||||
export interface DocumentRangeFormattingEditProvider {
|
||||
provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, options: FormattingOptions & FormattingOptions2, token: CancellationToken): ProviderResult<TextEdit[]>;
|
||||
}
|
||||
|
||||
export namespace languages {
|
||||
/**
|
||||
* Provide formatting edits for multiple ranges in a document.
|
||||
*
|
||||
* @param metadata Metadata about the provider.
|
||||
* The given ranges are hints and providers can decide to format a smaller
|
||||
* or larger range. Often this is done by adjusting the start and end
|
||||
* of the range to full syntax nodes.
|
||||
*
|
||||
* @param document The document in which the command was invoked.
|
||||
* @param ranges The ranges which should be formatted.
|
||||
* @param options Options controlling formatting.
|
||||
* @param token A cancellation token.
|
||||
* @return A set of text edits or a thenable that resolves to such. The lack of a result can be
|
||||
* signaled by returning `undefined`, `null`, or an empty array.
|
||||
*/
|
||||
export function registerDocumentRangeFormattingEditProvider(selector: DocumentSelector, provider: DocumentRangeFormattingEditProvider, metadata?: DocumentRangeFormattingEditProviderMetadata): Disposable;
|
||||
provideDocumentRangesFormattingEdits?(document: TextDocument, ranges: Range[], options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1325,10 +1325,10 @@
|
||||
https-proxy-agent "^5.0.0"
|
||||
proxy-from-env "^1.1.0"
|
||||
|
||||
"@vscode/sqlite3@5.1.2-vscode":
|
||||
version "5.1.2-vscode"
|
||||
resolved "https://registry.yarnpkg.com/@vscode/sqlite3/-/sqlite3-5.1.2-vscode.tgz#ba15962d23ad784a43ecbaaa22c93f17f93b2400"
|
||||
integrity sha512-CIH0BWzQJA97teb1f3aAoyylztPdg1WqThHEvVPWXr8UO0+VtIa+ha20Q2PGYV4AGfPtkPnhUrSYpJDxnVhW/g==
|
||||
"@vscode/sqlite3@5.1.3-vscode":
|
||||
version "5.1.3-vscode"
|
||||
resolved "https://registry.yarnpkg.com/@vscode/sqlite3/-/sqlite3-5.1.3-vscode.tgz#4fe81eb2422edef7b13869fe9d66663f4d925e93"
|
||||
integrity sha512-B5PNGHzfdnLiAQiC4YjOt0YETtxVfRcyIJya39RdNNFW63ApCznsu4m+jrW6r1sDFCPSSTNurAwx1Bl25FCQFw==
|
||||
dependencies:
|
||||
node-addon-api "^4.2.0"
|
||||
tar "^6.1.11"
|
||||
|
||||
Reference in New Issue
Block a user