From d441fd8e4599ad2859ffc3311a041b5a5a4fbd95 Mon Sep 17 00:00:00 2001 From: kasecato Date: Mon, 27 Jul 2020 22:45:31 +0900 Subject: [PATCH] Fixed #104 activate on enter --- src/Domain/Lang/DocommentDomainCSharp.ts | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Domain/Lang/DocommentDomainCSharp.ts b/src/Domain/Lang/DocommentDomainCSharp.ts index 62a05c1..6b0f96d 100644 --- a/src/Domain/Lang/DocommentDomainCSharp.ts +++ b/src/Domain/Lang/DocommentDomainCSharp.ts @@ -5,6 +5,7 @@ import { SyntacticAnalysisCSharp } from '../../SyntacticAnalysis/SyntacticAnalys import { StringUtil } from '../../Utility/StringUtil'; import { DocommentDomain } from '../DocommentDomain'; import { CodeType } from '../IDocommentDomain'; +import { CommentSyntax } from '../../Entity/Config/Contributes/Configuration'; export class DocommentDomainCSharp extends DocommentDomain { @@ -48,15 +49,25 @@ export class DocommentDomainCSharp extends DocommentDomain { this._isEnterKey = isEnterKey; // NG: Activate on Enter NOT '/' + const activeLine: string = this._vsCodeApi.ReadLineAtCurrent(); + let isActivateKeyDelimited: boolean; if (this._config.activateOnEnter) { if (!isEnterKey) { return false; } + if (this._config.syntax === CommentSyntax.delimited) { + isActivateKeyDelimited = SyntacticAnalysisCSharp.IsDocCommentStrict(activeLine, this._config.syntax); + } + } + + // NG: After Insert DocComment + const isAfterDocComment: boolean = (activeChar == ' ') && !isActivationKey && isEnterKey; + if (isAfterDocComment) { + return false; } // NG: '////' - const activeLine: string = this._vsCodeApi.ReadLineAtCurrent(); - if (isActivationKey) { + if (isActivationKey || isActivateKeyDelimited) { // NG: '////' if (!SyntacticAnalysisCSharp.IsDocCommentStrict(activeLine, this._config.syntax)) { return false; @@ -67,9 +78,8 @@ export class DocommentDomainCSharp extends DocommentDomain { return false; } } - // Comment Line - if (isEnterKey) { + else if (isEnterKey) { // NG: '////' const isInsertLineAbove = SyntacticAnalysisCSharp.IsInsertLineAbove(activeLine); if (isInsertLineAbove) {