mirror of
https://github.com/danbulant/monaco-yaml
synced 2026-06-19 14:31:13 +00:00
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:
parent
26b0d6ea96
commit
288c34cd37
2 changed files with 0 additions and 41 deletions
|
|
@ -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);
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
);
|
||||
|
|
|
|||
Loading…
Reference in a new issue