Skip to content

Commit

Permalink
Fixes microsoft/monaco-editor#1746: Add typings for all possible opti…
Browse files Browse the repository at this point in the history
…ons, even the global ones
  • Loading branch information
alexdima committed Jan 6, 2020
1 parent 6e8c7d2 commit d08120c
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 4 deletions.
2 changes: 1 addition & 1 deletion build/monaco/monaco.d.ts.recipe
Expand Up @@ -48,7 +48,7 @@ declare namespace monaco.editor {
#include(vs/editor/standalone/common/standaloneThemeService): BuiltinTheme, IStandaloneThemeData, IColors
#include(vs/editor/common/modes/supports/tokenization): ITokenThemeRule
#include(vs/editor/common/services/webWorker): MonacoWebWorker, IWebWorkerOptions
#include(vs/editor/standalone/browser/standaloneCodeEditor): IActionDescriptor, IStandaloneEditorConstructionOptions, IDiffEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor
#include(vs/editor/standalone/browser/standaloneCodeEditor): IActionDescriptor, IGlobalEditorOptions, IStandaloneEditorConstructionOptions, IDiffEditorConstructionOptions, IStandaloneCodeEditor, IStandaloneDiffEditor
export interface ICommandHandler {
(...args: any[]): void;
}
Expand Down
53 changes: 51 additions & 2 deletions src/vs/editor/standalone/browser/standaloneCodeEditor.ts
Expand Up @@ -77,10 +77,58 @@ export interface IActionDescriptor {
run(editor: ICodeEditor): void | Promise<void>;
}

/**
* Options which apply for all editors.
*/
export interface IGlobalEditorOptions {
/**
* The number of spaces a tab is equal to.
* This setting is overridden based on the file contents when `detectIndentation` is on.
* Defaults to 4.
*/
tabSize?: number;
/**
* Insert spaces when pressing `Tab`.
* This setting is overridden based on the file contents when detectIndentation` is on.
* Defaults to true.
*/
insertSpaces?: boolean;
/**
* Controls whether `tabSize` and `insertSpaces` will be automatically detected when a file is opened based on the file contents.
* Defaults to true.
*/
detectIndentation?: boolean;
/**
* Remove trailing auto inserted whitespace.
* Defaults to true.
*/
trimAutoWhitespace?: boolean;
/**
* Special handling for large files to disable certain memory intensive features.
* Defaults to true.
*/
largeFileOptimizations?: boolean;
/**
* Controls whether completions should be computed based on words in the document.
* Defaults to true.
*/
wordBasedSuggestions?: boolean;
/**
* Keep peek editors open even when double clicking their content or when hitting `Escape`.
* Defaults to false.
*/
stablePeek?: boolean;
/**
* Lines above this length will not be tokenized for performance reasons.
* Defaults to 20000.
*/
maxTokenizationLineLength?: number;
}

/**
* The options to create an editor.
*/
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions {
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions, IGlobalEditorOptions {
/**
* The initial model associated with this code editor.
*/
Expand Down Expand Up @@ -125,6 +173,7 @@ export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
}

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

public updateOptions(newOptions: IEditorOptions): void {
public updateOptions(newOptions: IEditorOptions & IGlobalEditorOptions): void {
applyConfigurationValues(this._configurationService, newOptions, false);
super.updateOptions(newOptions);
}
Expand Down
51 changes: 50 additions & 1 deletion src/vs/monaco.d.ts
Expand Up @@ -1047,10 +1047,58 @@ declare namespace monaco.editor {
run(editor: ICodeEditor): void | Promise<void>;
}

/**
* Options which apply for all editors.
*/
export interface IGlobalEditorOptions {
/**
* The number of spaces a tab is equal to.
* This setting is overridden based on the file contents when `detectIndentation` is on.
* Defaults to 4.
*/
tabSize?: number;
/**
* Insert spaces when pressing `Tab`.
* This setting is overridden based on the file contents when detectIndentation` is on.
* Defaults to true.
*/
insertSpaces?: boolean;
/**
* Controls whether `tabSize` and `insertSpaces` will be automatically detected when a file is opened based on the file contents.
* Defaults to true.
*/
detectIndentation?: boolean;
/**
* Remove trailing auto inserted whitespace.
* Defaults to true.
*/
trimAutoWhitespace?: boolean;
/**
* Special handling for large files to disable certain memory intensive features.
* Defaults to true.
*/
largeFileOptimizations?: boolean;
/**
* Controls whether completions should be computed based on words in the document.
* Defaults to true.
*/
wordBasedSuggestions?: boolean;
/**
* Keep peek editors open even when double clicking their content or when hitting `Escape`.
* Defaults to false.
*/
stablePeek?: boolean;
/**
* Lines above this length will not be tokenized for performance reasons.
* Defaults to 20000.
*/
maxTokenizationLineLength?: number;
}

/**
* The options to create an editor.
*/
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions {
export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions, IGlobalEditorOptions {
/**
* The initial model associated with this code editor.
*/
Expand Down Expand Up @@ -1095,6 +1143,7 @@ declare namespace monaco.editor {
}

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

0 comments on commit d08120c

Please sign in to comment.