Suppress extra indent after the end of dot chains
This commit is contained in:
@@ -86,11 +86,34 @@ export class Config {
|
||||
* [1]: https://github.com/Microsoft/vscode/issues/11514#issuecomment-244707076
|
||||
*/
|
||||
private configureLanguage() {
|
||||
if (this.typingContinueCommentsOnNewline && !this.configureLang) {
|
||||
if (this.configureLang) return;
|
||||
|
||||
let onEnterRules: vscode.OnEnterRule[] = [
|
||||
{
|
||||
// Carry indentation from the previous line
|
||||
beforeText: /^\s*$/,
|
||||
action: { indentAction: vscode.IndentAction.None },
|
||||
},
|
||||
{
|
||||
// After the end of a function/field chain,
|
||||
// with the semicolon on the same line
|
||||
beforeText: /^\s+\..*;/,
|
||||
action: { indentAction: vscode.IndentAction.Outdent },
|
||||
},
|
||||
{
|
||||
// After the end of a function/field chain,
|
||||
// with semicolon detached from the rest
|
||||
beforeText: /^\s+;/,
|
||||
previousLineText: /^\s+\..*/,
|
||||
action: { indentAction: vscode.IndentAction.Outdent },
|
||||
},
|
||||
];
|
||||
|
||||
if (this.typingContinueCommentsOnNewline) {
|
||||
const indentAction = vscode.IndentAction.None;
|
||||
|
||||
this.configureLang = vscode.languages.setLanguageConfiguration("rust", {
|
||||
onEnterRules: [
|
||||
onEnterRules = [
|
||||
...onEnterRules,
|
||||
{
|
||||
// Doc single-line comment
|
||||
// e.g. ///|
|
||||
@@ -131,14 +154,13 @@ export class Config {
|
||||
beforeText: /^(\ \ )*\ \*\/\s*$/,
|
||||
action: { indentAction, removeText: 1 },
|
||||
},
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
this.configureLang = vscode.languages.setLanguageConfiguration("rust", {
|
||||
onEnterRules,
|
||||
});
|
||||
}
|
||||
if (!this.typingContinueCommentsOnNewline && this.configureLang) {
|
||||
this.configureLang.dispose();
|
||||
this.configureLang = undefined;
|
||||
}
|
||||
}
|
||||
|
||||
// We don't do runtime config validation here for simplicity. More on stackoverflow:
|
||||
// https://stackoverflow.com/questions/60135780/what-is-the-best-way-to-type-check-the-configuration-for-vscode-extension
|
||||
|
||||
Reference in New Issue
Block a user