Skip to content

Commit 5418a56

Browse files
committed
Fixes microsoft/monaco-editor#1746: Add typings for all possible options, even the global ones
1 parent 36417c4 commit 5418a56

File tree

3 files changed

+102
-4
lines changed

3 files changed

+102
-4
lines changed

Diff for: build/monaco/monaco.d.ts.recipe

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ declare namespace monaco.editor {
4848
#include(vs/editor/standalone/common/standaloneThemeService): BuiltinTheme, IStandaloneThemeData, IColors
4949
#include(vs/editor/common/modes/supports/tokenization): ITokenThemeRule
5050
#include(vs/editor/common/services/webWorker): MonacoWebWorker, IWebWorkerOptions
51-
#include(vs/editor/standalone/browser/standaloneCodeEditor): IActionDescriptor, IStandaloneEditorConstructionOptions, IDiffEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor
51+
#include(vs/editor/standalone/browser/standaloneCodeEditor): IActionDescriptor, IGlobalEditorOptions, IStandaloneEditorConstructionOptions, IDiffEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor
5252
export interface ICommandHandler {
5353
(...args: any[]): void;
5454
}

Diff for: src/vs/editor/standalone/browser/standaloneCodeEditor.ts

+51-2
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,58 @@ export interface IActionDescriptor {
7777
run(editor: ICodeEditor): void | Promise<void>;
7878
}
7979

80+
/**
81+
* Options which apply for all editors.
82+
*/
83+
export interface IGlobalEditorOptions {
84+
/**
85+
* The number of spaces a tab is equal to.
86+
* This setting is overridden based on the file contents when `detectIndentation` is on.
87+
* Defaults to 4.
88+
*/
89+
tabSize?: number;
90+
/**
91+
* Insert spaces when pressing `Tab`.
92+
* This setting is overridden based on the file contents when detectIndentation` is on.
93+
* Defaults to true.
94+
*/
95+
insertSpaces?: boolean;
96+
/**
97+
* Controls whether `tabSize` and `insertSpaces` will be automatically detected when a file is opened based on the file contents.
98+
* Defaults to true.
99+
*/
100+
detectIndentation?: boolean;
101+
/**
102+
* Remove trailing auto inserted whitespace.
103+
* Defaults to true.
104+
*/
105+
trimAutoWhitespace?: boolean;
106+
/**
107+
* Special handling for large files to disable certain memory intensive features.
108+
* Defaults to true.
109+
*/
110+
largeFileOptimizations?: boolean;
111+
/**
112+
* Controls whether completions should be computed based on words in the document.
113+
* Defaults to true.
114+
*/
115+
wordBasedSuggestions?: boolean;
116+
/**
117+
* Keep peek editors open even when double clicking their content or when hitting `Escape`.
118+
* Defaults to false.
119+
*/
120+
stablePeek?: boolean;
121+
/**
122+
* Lines above this length will not be tokenized for performance reasons.
123+
* Defaults to 20000.
124+
*/
125+
maxTokenizationLineLength?: number;
126+
}
127+
80128
/**
81129
* The options to create an editor.
82130
*/
83-
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions {
131+
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions, IGlobalEditorOptions {
84132
/**
85133
* The initial model associated with this code editor.
86134
*/
@@ -125,6 +173,7 @@ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
125173
}
126174

127175
export interface IStandaloneCodeEditor extends ICodeEditor {
176+
updateOptions(newOptions: IEditorOptions & IGlobalEditorOptions): void;
128177
addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null;
129178
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
130179
addAction(descriptor: IActionDescriptor): IDisposable;
@@ -337,7 +386,7 @@ export class StandaloneEditor extends StandaloneCodeEditor implements IStandalon
337386
super.dispose();
338387
}
339388

340-
public updateOptions(newOptions: IEditorOptions): void {
389+
public updateOptions(newOptions: IEditorOptions & IGlobalEditorOptions): void {
341390
applyConfigurationValues(this._configurationService, newOptions, false);
342391
super.updateOptions(newOptions);
343392
}

Diff for: src/vs/monaco.d.ts

+50-1
Original file line numberDiff line numberDiff line change
@@ -1048,10 +1048,58 @@ declare namespace monaco.editor {
10481048
run(editor: ICodeEditor): void | Promise<void>;
10491049
}
10501050

1051+
/**
1052+
* Options which apply for all editors.
1053+
*/
1054+
export interface IGlobalEditorOptions {
1055+
/**
1056+
* The number of spaces a tab is equal to.
1057+
* This setting is overridden based on the file contents when `detectIndentation` is on.
1058+
* Defaults to 4.
1059+
*/
1060+
tabSize?: number;
1061+
/**
1062+
* Insert spaces when pressing `Tab`.
1063+
* This setting is overridden based on the file contents when detectIndentation` is on.
1064+
* Defaults to true.
1065+
*/
1066+
insertSpaces?: boolean;
1067+
/**
1068+
* Controls whether `tabSize` and `insertSpaces` will be automatically detected when a file is opened based on the file contents.
1069+
* Defaults to true.
1070+
*/
1071+
detectIndentation?: boolean;
1072+
/**
1073+
* Remove trailing auto inserted whitespace.
1074+
* Defaults to true.
1075+
*/
1076+
trimAutoWhitespace?: boolean;
1077+
/**
1078+
* Special handling for large files to disable certain memory intensive features.
1079+
* Defaults to true.
1080+
*/
1081+
largeFileOptimizations?: boolean;
1082+
/**
1083+
* Controls whether completions should be computed based on words in the document.
1084+
* Defaults to true.
1085+
*/
1086+
wordBasedSuggestions?: boolean;
1087+
/**
1088+
* Keep peek editors open even when double clicking their content or when hitting `Escape`.
1089+
* Defaults to false.
1090+
*/
1091+
stablePeek?: boolean;
1092+
/**
1093+
* Lines above this length will not be tokenized for performance reasons.
1094+
* Defaults to 20000.
1095+
*/
1096+
maxTokenizationLineLength?: number;
1097+
}
1098+
10511099
/**
10521100
* The options to create an editor.
10531101
*/
1054-
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions {
1102+
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions, IGlobalEditorOptions {
10551103
/**
10561104
* The initial model associated with this code editor.
10571105
*/
@@ -1096,6 +1144,7 @@ declare namespace monaco.editor {
10961144
}
10971145

10981146
export interface IStandaloneCodeEditor extends ICodeEditor {
1147+
updateOptions(newOptions: IEditorOptions & IGlobalEditorOptions): void;
10991148
addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null;
11001149
createContextKey<T>(key: string, defaultValue: T): IContextKey<T>;
11011150
addAction(descriptor: IActionDescriptor): IDisposable;

0 commit comments

Comments
 (0)