Skip to content

Commit

Permalink
! Refactored code
Browse files Browse the repository at this point in the history
  • Loading branch information
wmjordan committed May 16, 2023
1 parent 4118a22 commit eecb370
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions Codist/SmartBars/SmartBar.CommonEdit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,24 @@ void AddCutCommand() {

void AddDeleteCommand() {
AddCommand(ToolBar, IconIds.Delete, R.CMD_DeleteSelectedText, ctx => {
const string REMOVE_SPACE_BEFORE = "={<>(-+*/^!|?:~&%";
var s = ctx.View.Selection;
var t = s.GetFirstSelectionText();
if (s.Mode == TextSelectionMode.Stream
&& ctx.RightClick == false
&& s.IsEmpty == false) {
var end = s.End.Position;
// remove a trailing space
#region remove a trailing space
var snapshot = ctx.View.TextSnapshot;
if (end < snapshot.Length - 1
&& Char.IsLetterOrDigit(snapshot[end - 1])
&& snapshot[end] == ' '
&& (end == snapshot.Length - 2
|| "={<>(-+*/^!|?:~&%".IndexOf(snapshot[end.Position + 1]) == -1)) {
|| REMOVE_SPACE_BEFORE.IndexOf(snapshot[end.Position + 1]) == -1)) {
ctx.KeepToolBar(false);
s.Select(new SnapshotSpan(s.Start.Position, s.End.Position + 1), false);
}
#endregion
}
ExecuteAndFind(ctx, "Edit.Delete", t, false);
});
Expand Down

0 comments on commit eecb370

Please sign in to comment.