@@ -1757,17 +1757,20 @@ namespace ts {
17571757 function getFormattingEditsAfterKeystroke ( fileName : string , position : number , key : string , options : FormatCodeOptions | FormatCodeSettings ) : TextChange [ ] {
17581758 const sourceFile = syntaxTreeCache . getCurrentSourceFile ( fileName ) ;
17591759 const settings = toEditorSettings ( options ) ;
1760- if ( key === "{" ) {
1761- return formatting . formatOnOpeningCurly ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1762- }
1763- else if ( key === "}" ) {
1764- return formatting . formatOnClosingCurly ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1765- }
1766- else if ( key === ";" ) {
1767- return formatting . formatOnSemicolon ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1768- }
1769- else if ( key === "\n" ) {
1770- return formatting . formatOnEnter ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1760+
1761+ if ( ! isInComment ( sourceFile , position ) ) {
1762+ if ( key === "{" ) {
1763+ return formatting . formatOnOpeningCurly ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1764+ }
1765+ else if ( key === "}" ) {
1766+ return formatting . formatOnClosingCurly ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1767+ }
1768+ else if ( key === ";" ) {
1769+ return formatting . formatOnSemicolon ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1770+ }
1771+ else if ( key === "\n" ) {
1772+ return formatting . formatOnEnter ( position , sourceFile , getRuleProvider ( settings ) , settings ) ;
1773+ }
17711774 }
17721775
17731776 return [ ] ;
0 commit comments