Skip to content

Commit 17bc410

Browse files
committed
Merge pull request #1031 from fdorg/fix/brace-indent
Fix auto indent of closing brace
2 parents f8f0483 + 196ea3d commit 17bc410

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

External/Plugins/ASCompletion/Completion/ASComplete.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,13 +1008,16 @@ static private void HandleStructureCompletion(ScintillaControl Sci)
10081008
int line = Sci.LineFromPosition(position);
10091009
if (line == 0)
10101010
return;
1011-
string txt = Sci.GetLine(line-1).TrimEnd();
1011+
string txt = Sci.GetLine(line - 1).TrimEnd();
10121012
int style = Sci.BaseStyleAt(position);
10131013

1014+
// move closing brace to its own line and fix indentation
10141015
if (Sci.CurrentChar == '}')
10151016
{
1016-
Sci.DeleteForward();
1017-
AutoCloseBrace(Sci, line);
1017+
var openingBrace = Sci.SafeBraceMatch(position);
1018+
var openLine = openingBrace >= 0 ? Sci.LineFromPosition(openingBrace) : line - 1;
1019+
Sci.InsertText(Sci.CurrentPos, LineEndDetector.GetNewLineMarker(Sci.EOLMode));
1020+
Sci.SetLineIndentation(line + 1, Sci.GetLineIndentation(openLine));
10181021
}
10191022
// in comments
10201023
else if (PluginBase.Settings.CommentBlockStyle == CommentBlockStyle.Indented && txt.EndsWith("*/"))

0 commit comments

Comments
 (0)