提交 89a4f7a6 编写于 作者: R rebornix

AutoIndent: Type, put this feature behind a flag.

上级 e82a1bef
......@@ -401,6 +401,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.contribInfo.formatOnPaste,
'description': nls.localize('formatOnPaste', "Controls if the editor should automatically format the pasted content. A formatter must be available and the formatter should be able to format a range in a document.")
},
'editor.autoIndent': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.autoIndent,
'description': nls.localize('autoIndent', "Controls if the editor should automatically adjust the indenation when users type. Indentation Rules of the language must be available. ")
},
'editor.suggestOnTriggerCharacters': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.suggestOnTriggerCharacters,
......
......@@ -376,6 +376,11 @@ export interface IEditorOptions {
* Defaults to true.
*/
autoClosingBrackets?: boolean;
/**
* Enable auto indentation adjustment.
* Defaults to false.
*/
autoIndent?: boolean;
/**
* Enable format on type.
* Defaults to false.
......@@ -803,6 +808,7 @@ export interface IValidatedEditorOptions {
readonly wordWrapBreakAfterCharacters: string;
readonly wordWrapBreakObtrusiveCharacters: string;
readonly autoClosingBrackets: boolean;
readonly autoIndent: boolean;
readonly dragAndDrop: boolean;
readonly emptySelectionClipboard: boolean;
readonly useTabStops: boolean;
......@@ -833,6 +839,7 @@ export class InternalEditorOptions {
// ---- cursor options
readonly wordSeparators: string;
readonly autoClosingBrackets: boolean;
readonly autoIndent: boolean;
readonly useTabStops: boolean;
readonly tabFocusMode: boolean;
readonly dragAndDrop: boolean;
......@@ -858,6 +865,7 @@ export class InternalEditorOptions {
multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
wordSeparators: string;
autoClosingBrackets: boolean;
autoIndent: boolean;
useTabStops: boolean;
tabFocusMode: boolean;
dragAndDrop: boolean;
......@@ -877,6 +885,7 @@ export class InternalEditorOptions {
this.multiCursorModifier = source.multiCursorModifier;
this.wordSeparators = source.wordSeparators;
this.autoClosingBrackets = source.autoClosingBrackets;
this.autoIndent = source.autoIndent;
this.useTabStops = source.useTabStops;
this.tabFocusMode = source.tabFocusMode;
this.dragAndDrop = source.dragAndDrop;
......@@ -902,6 +911,7 @@ export class InternalEditorOptions {
&& this.multiCursorModifier === other.multiCursorModifier
&& this.wordSeparators === other.wordSeparators
&& this.autoClosingBrackets === other.autoClosingBrackets
&& this.autoIndent === other.autoIndent
&& this.useTabStops === other.useTabStops
&& this.tabFocusMode === other.tabFocusMode
&& this.dragAndDrop === other.dragAndDrop
......@@ -928,6 +938,7 @@ export class InternalEditorOptions {
multiCursorModifier: (this.multiCursorModifier !== newOpts.multiCursorModifier),
wordSeparators: (this.wordSeparators !== newOpts.wordSeparators),
autoClosingBrackets: (this.autoClosingBrackets !== newOpts.autoClosingBrackets),
autoIndent: (this.autoIndent !== newOpts.autoIndent),
useTabStops: (this.useTabStops !== newOpts.useTabStops),
tabFocusMode: (this.tabFocusMode !== newOpts.tabFocusMode),
dragAndDrop: (this.dragAndDrop !== newOpts.dragAndDrop),
......@@ -1268,6 +1279,7 @@ export interface IConfigurationChangedEvent {
readonly multiCursorModifier: boolean;
readonly wordSeparators: boolean;
readonly autoClosingBrackets: boolean;
readonly autoIndent: boolean;
readonly useTabStops: boolean;
readonly tabFocusMode: boolean;
readonly dragAndDrop: boolean;
......@@ -1445,6 +1457,7 @@ export class EditorOptionsValidator {
wordWrapBreakAfterCharacters: _string(opts.wordWrapBreakAfterCharacters, defaults.wordWrapBreakAfterCharacters),
wordWrapBreakObtrusiveCharacters: _string(opts.wordWrapBreakObtrusiveCharacters, defaults.wordWrapBreakObtrusiveCharacters),
autoClosingBrackets: _boolean(opts.autoClosingBrackets, defaults.autoClosingBrackets),
autoIndent: _boolean(opts.autoIndent, defaults.autoIndent),
dragAndDrop: _boolean(opts.dragAndDrop, defaults.dragAndDrop),
emptySelectionClipboard: _boolean(opts.emptySelectionClipboard, defaults.emptySelectionClipboard),
useTabStops: _boolean(opts.useTabStops, defaults.useTabStops),
......@@ -1670,6 +1683,7 @@ export class InternalEditorOptionsFactory {
wordWrapBreakAfterCharacters: opts.wordWrapBreakAfterCharacters,
wordWrapBreakObtrusiveCharacters: opts.wordWrapBreakObtrusiveCharacters,
autoClosingBrackets: opts.autoClosingBrackets,
autoIndent: opts.autoIndent,
dragAndDrop: opts.dragAndDrop,
emptySelectionClipboard: opts.emptySelectionClipboard,
useTabStops: opts.useTabStops,
......@@ -1876,6 +1890,7 @@ export class InternalEditorOptionsFactory {
multiCursorModifier: opts.multiCursorModifier,
wordSeparators: opts.wordSeparators,
autoClosingBrackets: opts.autoClosingBrackets,
autoIndent: opts.autoIndent,
useTabStops: opts.useTabStops,
tabFocusMode: opts.readOnly ? true : env.tabFocusMode,
dragAndDrop: opts.dragAndDrop,
......@@ -2089,6 +2104,7 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
wordWrapBreakAfterCharacters: ' \t})]?|&,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー’”〉》」』】〕)]}」',
wordWrapBreakObtrusiveCharacters: '.',
autoClosingBrackets: true,
autoIndent: false,
dragAndDrop: true,
emptySelectionClipboard: true,
useTabStops: true,
......
......@@ -64,6 +64,7 @@ export class CursorConfiguration {
public readonly wordSeparators: string;
public readonly emptySelectionClipboard: boolean;
public readonly autoClosingBrackets: boolean;
public readonly autoIndent: boolean;
public readonly autoClosingPairsOpen: CharacterMap;
public readonly autoClosingPairsClose: CharacterMap;
public readonly surroundingPairs: CharacterMap;
......@@ -99,6 +100,7 @@ export class CursorConfiguration {
this.wordSeparators = c.wordSeparators;
this.emptySelectionClipboard = c.emptySelectionClipboard;
this.autoClosingBrackets = c.autoClosingBrackets;
this.autoIndent = c.autoIndent;
this.autoClosingPairsOpen = {};
this.autoClosingPairsClose = {};
......
......@@ -595,12 +595,14 @@ export class TypeOperations {
});
}
let indentCommand = this._runAutoIndentType(config, model, selections[0], ch);
if (indentCommand) {
return new EditOperationResult([indentCommand], {
shouldPushStackElementBefore: true,
shouldPushStackElementAfter: false,
});
if (config.autoIndent) {
let indentCommand = this._runAutoIndentType(config, model, selections[0], ch);
if (indentCommand) {
return new EditOperationResult([indentCommand], {
shouldPushStackElementBefore: true,
shouldPushStackElementAfter: false,
});
}
}
if (this._isAutoClosingCloseCharType(config, model, selections, ch)) {
......
......@@ -2926,6 +2926,11 @@ declare module monaco.editor {
* Defaults to true.
*/
autoClosingBrackets?: boolean;
/**
* Enable auto indentation adjustment.
* Defaults to false.
*/
autoIndent?: boolean;
/**
* Enable format on type.
* Defaults to false.
......@@ -3284,6 +3289,7 @@ declare module monaco.editor {
readonly multiCursorModifier: 'altKey' | 'ctrlKey' | 'metaKey';
readonly wordSeparators: string;
readonly autoClosingBrackets: boolean;
readonly autoIndent: boolean;
readonly useTabStops: boolean;
readonly tabFocusMode: boolean;
readonly dragAndDrop: boolean;
......@@ -3416,6 +3422,7 @@ declare module monaco.editor {
readonly multiCursorModifier: boolean;
readonly wordSeparators: boolean;
readonly autoClosingBrackets: boolean;
readonly autoIndent: boolean;
readonly useTabStops: boolean;
readonly tabFocusMode: boolean;
readonly dragAndDrop: boolean;
......
......@@ -219,6 +219,7 @@ const configurationValueWhitelist = [
'editor.quickSuggestionsDelay',
'editor.parameterHints',
'editor.autoClosingBrackets',
'editor.autoindent',
'editor.formatOnType',
'editor.formatOnPaste',
'editor.suggestOnTriggerCharacters',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册