PavelTorgashov / FastColoredTextBox

Fast Colored TextBox for Syntax Highlighting. The text editor component for .NET.
Other
1.21k stars 463 forks source link

Control changes "==" to "= =" #254

Open Karbunkle1 opened 1 year ago

Karbunkle1 commented 1 year ago

Greetings,

Paste the following (3) line of text into FastColoredTextBox running instance: CreateSet DenySet1 From Claim As ( CPT = = "G0447" or (CPT == "G0473" and DOS >= '01/01/2020') ); If (GetRecCount(DenySet1)==0) EndRule;

On line #2, try to eliminate the space character between the two "=" equal signs following "CPT ". EDIT: Try this challenge using [DELETE] or [BACKSPACE] without selecting characters, but properly placing the cursor before or after the space between the (2) "=" signs. Placing the cursor after the second "=" sign in "= =" you will find that you cannot [BACKSPACE] and remove the equal sign.

Now paste the following (3) lines of text into FastColoredTextBox running instance: CreateSet DenySet1 From Claim As ( CPT = "G0447" or (CPT == "G0473" and DOS >= '01/01/2020') ); If (GetRecCount(DenySet1)==0) EndRule;

On line #2, try to change CPT = "G0447" to CPT == "G0447" by adding a second equals sign. You should see "= =" instead.

If you move this part: " and DOS >= '01/01/2020') );" to the third line by inserting a carriage-return/line feed, the control functions as expected and does not convert "==" to "= =" anymore.

This behavior is with Language set to 'Language.Custom'. From the form Designer.cs: // // txtRule // this.txtRule.AutoCompleteBracketsList = new char[] { '(', ')', '{', '}', '[', ']', '\"', '\"', '\'', '\''}; this.txtRule.AutoScrollMinSize = new System.Drawing.Size(29, 21); this.txtRule.BackBrush = null; this.txtRule.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30))))); this.txtRule.BlockCaretAlpha = ((byte)(255)); this.txtRule.CaretBlinking = false; this.txtRule.CaretColor = System.Drawing.Color.Snow; this.txtRule.CharHeight = 18; this.txtRule.CharWidth = 9; this.txtRule.ContextMenuStrip = this.contextMenu; this.txtRule.DisabledColor = System.Drawing.Color.FromArgb(((int)(((byte)(100)))), ((int)(((byte)(180)))), ((int)(((byte)(180)))), ((int)(((byte)(180))))); this.txtRule.Dock = System.Windows.Forms.DockStyle.Fill; this.txtRule.Font = new System.Drawing.Font("Consolas", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point); this.txtRule.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(210)))), ((int)(((byte)(210)))), ((int)(((byte)(170))))); this.txtRule.IsReplaceMode = false; this.txtRule.Location = new System.Drawing.Point(0, 48); this.txtRule.Name = "txtRule"; this.txtRule.Paddings = new System.Windows.Forms.Padding(0, 0, 0, 3); this.txtRule.SelectionColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(255))))); this.txtRule.Size = new System.Drawing.Size(927, 428); this.txtRule.TabIndex = 0; this.txtRule.Zoom = 100;

Karbunkle1 commented 1 year ago

I believe your AutoIndentCharsPattern would be improved by changing this: @"^\s[\w.]+\s(?<range>=)\s(?<range>[^;]+);" to this: @"^\s[\w.]+\s(?<range>=[=<>]?)\s(?<range>[^;]+);"

But either way, this will prevent the [DELETE] and [BACKSPACE] keys from operating intuitively when the current line is terminated with a ";" character. So really, either Regex pattern shown here is defective.