the-carlisle-group / Acre-Desktop

A simple Dyalog APL IDE plugin that introduces "projects" and allows you to keep your source code in Unicode text files.
MIT License
11 stars 1 forks source link

acre does not handle changes under some strange circumstances #231

Closed aplteam closed 4 years ago

aplteam commented 4 years ago

I changed a class and acre did not report any action in the session. I changed some other classes and all was fine. Only with one particular class go things south.

Investigation showed that in editFix on line 12 acre stops dead. Further investigation showed that in ssp the expression ⎕NC ⍵ returns a ¯1.

Why does ⎕NC return ¯1:

⎕se.aplteam.Display ⍵
┌→──────────────────────┐
│ ┌→──────────────────┐ │
│ │#.Execute.Execute  │ │
│ └───────────────────┘ │
└∊──────────────────────┘
      ⎕UCS 0⊃⍵
35 46 69 120 101 99 117 116 101 46 69 120 101 99 117 116 101 9 9

Because the last two characters are TABs!

Where do they come from? The right argument passed on to editFix:

      (4⊃⍵),'|'
Execute|
      (5⊃⍵),'|'
Execute     |
      ⎕ucs 5⊃⍵
69 120 101 99 117 116 101 9 9

name (4) is okay, but new (5) is not.

This is clearly a Dyalog bug which I am going to report right now.

I suggest that acre should check the result of ⎕NC. The result ¯1 should be impossible at this point of course, but it happened anyway, so acre should report this as a fatal error.

aplteam commented 4 years ago

It's not exactly a Dyalog bug: the problem pops up because the script actually contains two trailing TAB characters at the end of the first line which in an editor reads:

:Class Execute

Since it is unclear whether Dyalog is going to do something about this I think it's clear that acre needs to do it's own checking. It could either throw away all white space characters after the name or at least throw an error in case the result of ⎕NC is ¯1.

PhilLast commented 4 years ago

Having looked at all classes within the acre project:

 #.acre.AcreDesktop_Testcases.Execute      
 #.acre.AcreDesktop_Testcases.FilesAndDirs 
 #.acre.AcreDesktop_Testcases.IniFiles     
 #.acre.AcreDesktop_Testcases.OS           
 #.acre.AcreDesktop_Testcases.Tester2      
 #.acre.AcreDesktop_Testcases.WinReg       

I found:

      ⎕ucs ⊃⎕src #.acre.AcreDesktop_Testcases.Execute 
58 67 108 97 115 115 32 69 120 101 99 117 116 101 9 9

I never touched it, Guv, honest!

PhilLast commented 4 years ago

If I edit a class and hit the tab-key at the end of the first line Dyalog adds blanks to bring the length to the next multiple of four for each key-stroke.

If I do the same in notepad it adds one HT for each.

Either seems to be acceptable to ⎕FIX.

The problem is then in the FIX event message itself in that it removes them in one case and not the other.

PhilLast commented 4 years ago

The culprit is

:Class Execute           
⍝ This class allows you two different things:
...

that has the two tabs at the end of the first line in its source. ⎕FIX doesn't mind but they are left in in the second instance of the name in the Fix event message. They must have been input at some time in the past in an external editor. Because the new name was invalid acre ignored all changes and didn't save the class. This could have happened at any time in the past decade for all I know but presumably the class wasn't edited in acre.

Acre will now ignore an invalid new name and save under the old. This will allow changes to the same object in the above case without removing the tabs but will honour a genuine name change without them.

PhilLast commented 4 years ago

Done