Remove DocumentRangeFormattingEditProvider

The YAML language service doesn’t support formatting ranges.

In practice this means the “Format Selection” option which does the same
as “Format Document” is no longer available in the menu that’s opened
when pressing F1.
This commit is contained in:
Remco Haszing 2021-08-18 15:47:50 +02:00
parent 26b0d6ea96
commit 288c34cd37
No known key found for this signature in database
GPG key ID: 40D9F5FE9155FD3C
2 changed files with 0 additions and 41 deletions

View file

@ -2,7 +2,6 @@ import {
editor,
IDisposable,
IMarkdownString,
IRange,
languages,
MarkerSeverity,
Position,
@ -152,18 +151,6 @@ function fromPosition(position: Position): ls.Position {
return { character: position.column - 1, line: position.lineNumber - 1 };
}
function fromRange(range: IRange): ls.Range {
if (!range) {
return;
}
return {
start: {
line: range.startLineNumber - 1,
character: range.startColumn - 1,
},
end: { line: range.endLineNumber - 1, character: range.endColumn - 1 },
};
}
function toRange(range: ls.Range): Range {
if (!range) {
return;
@ -454,27 +441,3 @@ export class DocumentFormattingEditProvider implements languages.DocumentFormatt
);
}
}
export class DocumentRangeFormattingEditProvider
implements languages.DocumentRangeFormattingEditProvider {
constructor(private _worker: WorkerAccessor) {}
provideDocumentRangeFormattingEdits(
model: editor.IReadOnlyModel,
range: Range,
options: languages.FormattingOptions,
): PromiseLike<editor.ISingleEditOperation[]> {
const resource = model.uri;
return this._worker(resource).then((worker) =>
worker
.format(String(resource), fromRange(range), fromFormattingOptions(options))
.then((edits) => {
if (!edits || edits.length === 0) {
return;
}
return edits.map(toTextEdit);
}),
);
}
}

View file

@ -62,10 +62,6 @@ export function setupMode(defaults: LanguageServiceDefaultsImpl): void {
languageId,
new languageFeatures.DocumentFormattingEditProvider(worker),
),
languages.registerDocumentRangeFormattingEditProvider(
languageId,
new languageFeatures.DocumentRangeFormattingEditProvider(worker),
),
new languageFeatures.DiagnosticsAdapter(languageId, worker, defaults),
languages.setLanguageConfiguration(languageId, richEditConfiguration),
);