ide/CodeEditor; ecere/gui/EditBox: Fixed CodeEditor/Designer issues caused by aa2c3d3...
authorJerome St-Louis <jerome@ecere.com>
Wed, 26 Mar 2014 04:04:55 +0000 (00:04 -0400)
committerJerome St-Louis <jerome@ecere.com>
Wed, 26 Mar 2014 04:04:55 +0000 (00:04 -0400)
- Now doing this in the IDE CodeEditor instead
- Because this was done directly on the buffer, it would mess up several things including code locations and undo actions
- Editing with the designer or property/method sheets or auto complete safter a save trimming spaces would seriously mess up the code.
- Highlighted (red) spaces would not go away after going to the designer and come back prior to Save

ecere/src/gui/controls/EditBox.ec
ide/src/designer/CodeEditor.ec

index 694e6fc..e7f49d7 100644 (file)
@@ -6123,21 +6123,7 @@ public:
 
       for(line = this.lines.first; line; line = line.next)
       {
-         if(style.syntax && line.count && isspace(line.buffer[line.count-1]))
-         {
-            int c = 0;
-            for(c=line.count-2; c>=-1; c--)
-            {
-               if(c == -1 || !isspace(line.buffer[c]))
-               {
-                  c++;
-                  line.buffer[c] = '\0';
-                  line.count -= (line.count - c);
-                  break;
-               }
-            }
-         }
-         f.Write(line.buffer, line.count,1);
+         f.Write(line.buffer, line.count, 1);
          if(line.next)
          {
             if(cr) f.Putc('\r');
index 524d839..346c3b5 100644 (file)
@@ -2204,6 +2204,22 @@ class CodeEditor : Window
             designer.fileName = fileName;
             designer.modifiedDocument = false;
          }
+
+         if(editBox.syntaxHighlighting)
+         {
+            // Nuke trailing spaces
+            EditLine line;
+            int y = 0;
+            for(line = editBox.firstLine; line; line = line.next, y++)
+            {
+               String buffer = line.text;
+               int count = line.count, i = count-1;
+               while(i > 0 && isspace(buffer[i])) i--;
+               if(i < count - 1)
+                  editBox.Delete(line, y, i, line, y, count);
+            }
+         }
+
          editBox.Save(f, false);
          modifiedDocument = false;