提交 4260db3e 编写于 作者: R rebornix

enrich unindent rule and indentNextLine rule

上级 0f0e4606
......@@ -286,7 +286,7 @@ export class LanguageConfigurationRegistryImpl {
return result;
}
public getEnterActionForSelection(model: ITokenizedModel, range: Range): { enterAction: EnterAction; indentation: string; ignoreCurrentLine: boolean} {
public getEnterActionForSelection(model: ITokenizedModel, range: Range): { enterAction: EnterAction; indentation: string; ignoreCurrentLine: boolean } {
let lineNumber = range.startLineNumber;
let column = range.startColumn;
let lineText = model.getLineContent(lineNumber);
......@@ -300,7 +300,7 @@ export class LanguageConfigurationRegistryImpl {
let onEnterSupport = this._getOnEnterSupport(scopedLineTokens.languageId);
if (!onEnterSupport) {
return {
enterAction: {
enterAction: {
indentAction: IndentAction.None,
appendText: '',
},
......@@ -321,7 +321,7 @@ export class LanguageConfigurationRegistryImpl {
if (lastLineNumber <= 0) {
return {
enterAction: { indentAction : IndentAction.None, appendText: '' },
enterAction: { indentAction: IndentAction.None, appendText: '' },
indentation: '',
ignoreCurrentLine: true
};
......
......@@ -89,10 +89,10 @@ export class OnEnterSupport {
* even if there is nothing to outdent from.
*/
if (this._indentationRules.decreaseIndentPattern && this._indentationRules.decreaseIndentPattern.test(afterEnterText)) {
indentOffset = indentOffset ? indentOffset - 1 : -1;
indentOffset = indentOffset ? indentOffset - 1 : -1;
}
if (this._indentationRules.indentNextLinePattern && this._indentationRules.indentNextLinePattern.test(oneLineAboveText)) {
indentOffset = indentOffset ? indentOffset - 1 : -1;
indentOffset = indentOffset ? indentOffset - 1 : -1;
}
if (this._indentationRules.decreaseIndentPattern && this._indentationRules.decreaseIndentPattern.test(beforeEnterText)) {
outdentCurrentLine = true;
......@@ -103,11 +103,11 @@ export class OnEnterSupport {
indentOffset = indentOffset || 0;
switch (indentOffset) {
case -1:
return { indentAction : IndentAction.Outdent, outdentCurrentLine: outdentCurrentLine };
return { indentAction: IndentAction.Outdent, outdentCurrentLine: outdentCurrentLine };
case 0:
return { indentAction : IndentAction.None, outdentCurrentLine: outdentCurrentLine };
return { indentAction: IndentAction.None, outdentCurrentLine: outdentCurrentLine };
case 1:
return { indentAction : IndentAction.Indent, outdentCurrentLine: outdentCurrentLine };
return { indentAction: IndentAction.Indent, outdentCurrentLine: outdentCurrentLine };
}
}
}
......
......@@ -2837,10 +2837,10 @@ suite('Editor Controller - Cursor Configuration', () => {
suite('Editor Controller - Indentation Rules', () => {
let mode = new IndentRulesMode({
decreaseIndentPattern: /^\s*((?!\S.*\/[*]).*[*]\/\s*)?[})\]]|^\s*(case\b.*|default):\s*(\/\/.*|\/[*].*[*]\/\s*)?$/,
increaseIndentPattern: /(\{[^}"']*|\([^)"']*|\[[^\]"']*|^\s*(\{\}|\(\)|\[\]|(case\b.*|default):))\s*(\/\/.*|\/[*].*[*]\/\s*)?$/,
indentNextLinePattern: /^\s*(for|while|if|else)\b(?!.*[;{}]\s*(\/\/.*|\/[*].*[*]\/\s*)?$)/,
unIndentedLinePattern: /^(?!.*([;{}]|\S:)\s*(\/\/.*|\/[*].*[*]\/\s*)?$)(?!.*(\{[^}"']*|\([^)"']*|\[[^\]"']*|^\s*(\{\}|\(\)|\[\]|(case\b.*|default):))\s*(\/\/.*|\/[*].*[*]\/\s*)?$)(?!^\s*((?!\S.*\/[*]).*[*]\/\s*)?[})\]]|^\s*(case\b.*|default):\s*(\/\/.*|\/[*].*[*]\/\s*)?$)(?!^\s*(for|while|if|else)\b(?!.*[;{}]\s*(\/\/.*|\/[*].*[*]\/\s*)?$))/
decreaseIndentPattern: /^\s*((?!\S.*\/[*]).*[*]\/\s*)?[})\]]|^\s*(case\b.*|default):\s*(\/\/.*|\/[*].*[*]\/\s*)?$/,
increaseIndentPattern: /(\{[^}"']*|\([^)"']*|\[[^\]"']*|^\s*(\{\}|\(\)|\[\]|(case\b.*|default):))\s*(\/\/.*|\/[*].*[*]\/\s*)?$/,
indentNextLinePattern: /^\s*(for|while|if|else)\b(?!.*[;{}]\s*(\/\/.*|\/[*].*[*]\/\s*)?$)/,
unIndentedLinePattern: /^(?!.*([;{}]|\S:)\s*(\/\/.*|\/[*].*[*]\/\s*)?$)(?!.*(\{[^}"']*|\([^)"']*|\[[^\]"']*|^\s*(\{\}|\(\)|\[\]|(case\b.*|default):))\s*(\/\/.*|\/[*].*[*]\/\s*)?$)(?!^\s*((?!\S.*\/[*]).*[*]\/\s*)?[})\]]|^\s*(case\b.*|default):\s*(\/\/.*|\/[*].*[*]\/\s*)?$)(?!^\s*(for|while|if|else)\b(?!.*[;{}]\s*(\/\/.*|\/[*].*[*]\/\s*)?$))/
});
test('Enter honors increaseIndentPattern', () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册