Class FormattingTabSize
- Namespace
- RDCore.SDK.Formatting
- Assembly
- RDCore.SDK.dll
Takes the tab size of the client's editor as Formatting.IndentSpaces when the user never set one, through the configuration the client owns.
public static class FormattingTabSize
- Inheritance
-
FormattingTabSize
- Inherited Members
Remarks
A client owns its configuration (LSP 3.17 §Configuration Request), so a server sets nothing of it and tells the editor nothing: the flow is one way,
from the client to the server. A change of the editor's tab size is a change of configuration like any other. The server asks for two things whenever the client says
the configuration changed (workspace/didChangeConfiguration, then workspace/configuration): the platform's live settings
(Section), which hold Formatting.IndentSpaces when the user set it, and the editor's own EditorSection
(RequestEditorTabSizeAsync(ILanguageServerFacade, CancellationToken)).
When Formatting.IndentSpaces was never set, it is the editor's tab size for as long as the server runs: nothing is written, and a client that stops saying a tab
size takes it back to the default. When both are set and differ, Formatting.IndentSpaces is what the server has. A client that wants the editor to follow the
setting sets its own tab size from it.
Fields
EditorSection
The configuration section of the client's editor that carries its tab size, which the server asks for besides Section.
public const string EditorSection = "editor.tabSize"
Field Value
Methods
AdoptedFrom(IReadOnlyDictionary<string, string>, int?)
The settings the server takes for the ones the client did not say: the editor's tab size as the indentation, when the user never set one.
public static IReadOnlyDictionary<string, string> AdoptedFrom(IReadOnlyDictionary<string, string> said, int? editorTabSize)
Parameters
saidIReadOnlyDictionary<string, string>What the client said the live settings are, by their keys under Root, separated by
:.editorTabSizeint?The tab size of the client's editor; null when the client has none to say.
Returns
- IReadOnlyDictionary<string, string>
The indentation, by its key; none when the user set it or the editor has no tab size.
EditorTabSizeOf(JToken?)
The tab size of the client's editor, from what the client answered.
public static int? EditorTabSizeOf(JToken? answer)
Parameters
answerJTokenThe client's answer for EditorSection: a number, or the number as text.
Returns
RequestEditorTabSizeAsync(ILanguageServerFacade, CancellationToken)
Asks the client for the tab size of its editor (workspace/configuration, EditorSection).
public static Task<int?> RequestEditorTabSizeAsync(ILanguageServerFacade server, CancellationToken token = default)
Parameters
serverILanguageServerFacadeThe language server.
tokenCancellationTokenA token that cancels the request.
Returns
- Task<int?>
The tab size; null when the client does not have configuration to ask, answered with an error, or said one the indentation cannot be. A request that is cancelled, or whose connection is lost, throws: it is no answer, and the editor has not said it has no tab size.
Remarks
OmniSharp's own configuration keeps what a client answers only when it is an object, and the tab size is a number: it is asked for as a request of its own.