@@ -26,17 +26,65 @@ void SpaceAnalyzer::Analyze(FormatState &f, const LuaSyntaxTree &t) {
2626 break ;
2727 }
2828 case TK_CONCAT: {
29- if (!f.GetStyle ().space_around_concat_operator &&
30- syntaxNode.GetPrevToken (t).GetTokenKind (t) != TK_NUMBER) {
31- SpaceAround (syntaxNode, t, 0 );
32- break ;
29+ switch (f.GetStyle ().space_around_concat_operator ){
30+ case SpaceAroundStyle::Always: {
31+ SpaceAround (syntaxNode, t, 1 );
32+ break ;
33+ }
34+ case SpaceAroundStyle::None: {
35+ if (syntaxNode.GetPrevToken (t).GetTokenKind (t) == TK_NUMBER) {
36+ SpaceAround (syntaxNode, t, 1 );
37+ }
38+ else {
39+ SpaceAround (syntaxNode, t, 0 );
40+ }
41+ break ;
42+ }
43+ case SpaceAroundStyle::NoSpaceAsym: {
44+ if (syntaxNode.GetPrevToken (t).GetTokenKind (t) == TK_NUMBER) {
45+ SpaceLeft (syntaxNode, t, 1 );
46+ SpaceRight (syntaxNode, t, 0 );
47+ }
48+ else {
49+ SpaceAround (syntaxNode, t, 0 );
50+ }
51+ break ;
52+ }
53+ default : {
54+ break ;
55+ }
3356 }
34-
35- SpaceAround (syntaxNode, t, 1 );
3657 break ;
3758 }
3859 case ' =' : {
39- SpaceAround (syntaxNode, t, f.GetStyle ().space_around_assign_operator ? 1 : 0 );
60+ switch (f.GetStyle ().space_around_assign_operator ){
61+ case SpaceAroundStyle::Always: {
62+ SpaceAround (syntaxNode, t, 1 );
63+ break ;
64+ }
65+ case SpaceAroundStyle::None: {
66+ if (syntaxNode.GetPrevToken (t).GetTokenKind (t) == ' >' ) {
67+ SpaceAround (syntaxNode, t, 1 );
68+ }
69+ else {
70+ SpaceAround (syntaxNode, t, 0 );
71+ }
72+ break ;
73+ }
74+ case SpaceAroundStyle::NoSpaceAsym: {
75+ if (syntaxNode.GetPrevToken (t).GetTokenKind (t) == ' >' ) {
76+ SpaceLeft (syntaxNode, t, 1 );
77+ SpaceRight (syntaxNode, t, 0 );
78+ }
79+ else {
80+ SpaceAround (syntaxNode, t, 0 );
81+ }
82+ break ;
83+ }
84+ default : {
85+ break ;
86+ }
87+ }
4088 break ;
4189 }
4290 case TK_GE:
0 commit comments