Skip to content

Commit 2ad377b

Browse files
committed
Fix indent on newline on while in {}-braces caused by smart-indent, some cleanup
1 parent 4545e3e commit 2ad377b

3 files changed

Lines changed: 33 additions & 10 deletions

File tree

External/Plugins/ASCompletion/Completion/ASComplete.cs

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ static public bool OnShortcut(Keys keys, ScintillaControl Sci)
260260
}
261261
else if (keys == Keys.Back)
262262
{
263-
HandleAddClosingBraces(Sci, (char)Sci.CharAt(Sci.CurrentPos), false);
263+
HandleAddClosingBraces(Sci, Sci.CurrentChar, false);
264264
return false;
265265
}
266266
// show calltip
@@ -437,10 +437,9 @@ private static void HandleAddBrace(ScintillaControl sci, char c, Braces braces)
437437
else if (c == braces.closing)
438438
{
439439
// already a closing brace?
440-
if ((char)sci.CharAt(sci.CurrentPos) == braces.closing)
440+
if (sci.CurrentChar == braces.closing)
441441
{
442-
sci.SetSel(sci.CurrentPos + 1, sci.CurrentPos + 1);
443-
sci.DeleteBack();
442+
sci.DeleteForward();
444443
}
445444
}
446445
}
@@ -452,8 +451,7 @@ private static void HandleRemoveBrace(ScintillaControl sci, char c, Braces brace
452451
{
453452
if ((char)sci.CharAt(sci.CurrentPos - 1) == braces.opening)
454453
{
455-
sci.SetSel(sci.CurrentPos + 1, sci.CurrentPos + 1);
456-
sci.DeleteBack();
454+
sci.DeleteForward();
457455
}
458456
}
459457
}
@@ -1011,8 +1009,13 @@ static private void HandleStructureCompletion(ScintillaControl Sci)
10111009
string txt = Sci.GetLine(line-1).TrimEnd();
10121010
int style = Sci.BaseStyleAt(position);
10131011

1014-
// in comments
1015-
if (PluginBase.Settings.CommentBlockStyle == CommentBlockStyle.Indented && txt.EndsWith("*/"))
1012+
if (Sci.CurrentChar == '}')
1013+
{
1014+
Sci.DeleteForward();
1015+
AutoCloseBrace(Sci, line);
1016+
}
1017+
// in comments
1018+
else if (PluginBase.Settings.CommentBlockStyle == CommentBlockStyle.Indented && txt.EndsWith("*/"))
10161019
FixIndentationAfterComments(Sci, line);
10171020
else if (IsCommentStyle(style) && (Sci.BaseStyleAt(position + 1) == style))
10181021
FormatComments(Sci, txt, line);

External/Plugins/BasicCompletion/PluginMain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ private void SciControlCharAdded(ScintillaControl sci, Int32 value)
426426
Language config = ScintillaControl.Configuration.GetLanguage(lang);
427427
String characters = config.characterclass.Characters;
428428
// Do not autocomplete in word
429-
Char c = (char)sci.CharAt(sci.CurrentPos);
429+
Char c = sci.CurrentChar;
430430
if (characters.IndexOf(c) >= 0) return;
431431
// Autocomplete after typing word chars only
432432
if (characters.IndexOf((char)value) < 0) return;

PluginCore/ScintillaNet/ScintillaControl.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,6 +937,17 @@ public int CurrentPos
937937
SPerform(2141, (uint)value , 0);
938938
}
939939
}
940+
941+
/// <summary>
942+
/// Returns the chracter at the caret posiion.
943+
/// </summary>
944+
public char CurrentChar
945+
{
946+
get
947+
{
948+
return (char)CharAt(CurrentPos);
949+
}
950+
}
940951

941952
/// <summary>
942953
/// Returns the position of the opposite end of the selection to the caret.
@@ -3852,7 +3863,16 @@ public void Cancel()
38523863
public void DeleteBack()
38533864
{
38543865
SPerform(2326, 0, 0);
3855-
}
3866+
}
3867+
3868+
/// <summary>
3869+
/// Delete the character after the caret.
3870+
/// </summary>
3871+
public void DeleteForward()
3872+
{
3873+
SetSel(CurrentPos + 1, CurrentPos + 1);
3874+
DeleteBack();
3875+
}
38563876

38573877
/// <summary>
38583878
/// If selection is empty or all on one line replace the selection with a tab character.

0 commit comments

Comments
 (0)