Skip to content

Commit b49c4bc

Browse files
committed
Fix for #129
1 parent ce4c9aa commit b49c4bc

18 files changed

+175
-4550
lines changed

APLSource/Cider/GetCiderGlobalConfigFileContent.aplf

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
1-
r←GetCiderGlobalConfigFileContent;filename;json;qdmx
1+
r←GetCiderGlobalConfigFileContent;filename;json;qdmx;txt
22
⍝ Returns a namespace with all settings (if any) in the (optional) global Cider config file.
3-
Note that the file might not exist or be empty, in which case `⍬` is returned.
3+
If the file does not exist it is created.
44
r←⍬
55
filename←GetCiderGlobalConfigFilename
6-
:If F.IsFile filename
7-
:Trap 0
8-
json←F.NGET filename
9-
:Else
10-
qdmx←⎕DMX
11-
('Reading Cider''s global configuration file "',filename,'" failed: ',2⊃qdmx.DM)Assert 0
12-
:EndTrap
13-
:AndIf 0<≢json
6+
:If ~F.IsFile filename
7+
⍝ Create a global Cider config file with default entries (all comments)
8+
txt←''
9+
txt,←⊂,'{'
10+
txt,←⊂,' // AskForDirChange: 1,'
11+
txt,←⊂,' // CheckForDropboxConflicts: 0,'
12+
txt,←⊂,' // HandleLinkStops: 0,'
13+
txt,←⊂,' // ExecuteAfterProjectOpen: "",' ⍝ ⎕SE.Path2Function for example
14+
txt,←⊂,' // ReportGitStatus: 1,'
15+
txt,←⊂,' // verbose: 0,'
16+
txt,←⊂,'}'
17+
(⊂txt)⎕NPUT filename
18+
:EndIf
19+
:Trap 0
20+
json←⊃F.NGET filename
21+
:Else
22+
qdmx←⎕DMX
23+
('Reading Cider''s global configuration file "',filename,'" failed: ',2⊃qdmx.DM)Assert 0
24+
:EndTrap
25+
:If 0<≢json
1426
:Trap 0
15-
r←⎕JSON⍠('Dialect' 'JSON5')⊣json
27+
r←⎕JSON⍠('Dialect' 'JSON5')⊣json
1628
:Else
1729
qdmx←⎕DMX
1830
('Reading Cider''s global configuration file "',filename,'" failed: ',2⊃qdmx.DM)Assert 0

APLSource/Cider/GetCiderGlobalConfigFilename.aplf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
txt,←⊂,'{'
99
txt,←⊂,' // AskForDirChange: 1,'
1010
txt,←⊂,' // CheckForDropboxConflicts: 0,'
11+
txt,←⊂,' // HandleLinkStops: 0,'
1112
txt,←⊂,' // ExecuteAfterProjectOpen: "",' ⍝ ⎕SE.Path2Function for example
1213
txt,←⊂,' // ReportGitStatus: 1,'
1314
txt,←⊂,' // verbose: 0,'

APLSource/Cider/GetGlobalHandleLinkStops.aplf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
r←GetGlobalHandleLinkStops;globalUserConfig
22
⍝ Checks whether Cider's global configuration file carries a value for `HandleLinkStops`,
33
⍝ and if so, returns its value.
4+
⍝ As a side effect this function calls HandleLinkStops in case HandleLinkStops ←→ 2
45
r←0
56
:If ⍬≢globalUserConfig←GetCiderGlobalConfigFileContent
67
:AndIf 2=globalUserConfig.⎕NC'HandleLinkStops'
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,38 @@
1-
{r}←HandleLinkSourceFlags path;linkcfgFile;linkconfig;nameList;opCode;q;checkForDelete
1+
{r}←HandleLinkSourceFlags path;linkcfgFile;linkconfig;nameList;opCode;q;deleteFlag
22
⍝ Stops and traces are potentially stored in a file .link.config
33
⍝ If such a file exists and carries SourceFlags *and* the global Cider setting `HandleLinkStops` is greater
44
⍝ than 0 then this function takes action://
55
⍝ * HandleLinkStops=1 the user is asked whether she wants to erase stop and trace settings from `.linkconfig`
66
⍝ * HandleLinkStops=2 stop and trace settings are erase from `.linkconfig` without asking\\
77
⍝ The file will be deleted if it does not contain anything but the Link version the file was written with.
88
⍝ `path` must be the source folder of a project; that's where Link stores the `.linkconfig` file.
9+
⍝ Returns 0 for "na action taken", 1 for "file was deleted" and 2 for "file was changed".
10+
r←0
911
linkcfgFile←path,'/.linkconfig'
1012
:If F.IsFile linkcfgFile
1113
linkconfig←Get_JSON5 linkcfgFile
1214
nameList←(linkconfig.⎕NL-2 9)~⊂'LinkVersion'
1315
:AndIf (⊂'SourceFlags')∊nameList
1416
opCode←GetGlobalHandleLinkStops
1517
:AndIf 0<opCode
16-
checkForDelete←0
18+
deleteFlag←0
1719
:If 2=opCode
18-
∘∘∘
19-
checkForDelete←1
20-
:Else
20+
linkconfig.⎕EX'SourceFlags'
21+
deleteFlag←1
22+
:ElseIf 0=≢nameList~⊂'SourceFlags'
2123
q←'StopsAndTraces@There are ',⊃{⍺,' and ',⍵}/(0<⊃¨linkconfig.SourceFlags.⎕NC'Stop' 'Trace')/'stops' 'traces'
2224
q,←' saved in .linkconfig',(⎕UCS 13),'Would you like to delete those?'
2325
:If 1 CommTools.YesOrNo q
2426
linkconfig.⎕EX'SourceFlags'
25-
checkForDelete←1
27+
deleteFlag←1
2628
:EndIf
2729
:EndIf
28-
:If checkForDelete
30+
:If deleteFlag
2931
:AndIf 0=≢nameList~⊂'SourceFlags'
3032
F.DeleteFile linkcfgFile ⍝ There was nothing else in it, se we delete it
33+
r←1
3134
:Else
3235
linkconfig Put_JSON5 linkcfgFile ⍝ There is other stuff as well, so we write it back
36+
r←2
3337
:EndIf
3438
:EndIf

APLSource/Cider/History.apla

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
(
2+
'* 0.51.1 ⋄ 2026-03-04'
3+
' * Fix for issue #129 including test cases'
24
'* 0.51.0 ⋄ 2026-03-03'
35
' * ]ListAliases now marks folders that are not available anymore (#92)'
46
' * Aliase are now checked for starting with a letter followed by zero or more letters, digits, underscores or hyphens'

APLSource/TestCases/Test_Misc_015.aplf

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
→T.PassesIf 0<≢res
77
res←##.Cider.GetCiderAliasFilename
88
→T.PassesIf∨/'/aliase.txt'⍷FilesAndDirs.EnforceSlash res
9-
res←##.Cider.GetCiderGlobalConfigFileContent
10-
res←##.Cider.GetCiderGlobalConfigFilename
11-
→T.PassesIf∨/'/config.json'⍷FilesAndDirs.EnforceSlash res
9+
⍝ ##.Cider.GetCiderGlobalConfigFilename has its own test cases
1210
res←##.Cider.GetCiderGlobalConfigHomeFolder
1311
→T.PassesIf∨/'/.cider/'⍷FilesAndDirs.EnforceSlash res
1412

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
r←Test_Misc_020(stopFlag batchFlag);⎕TRAP;name;rc;en;msg;globalConfig;targetFolder;sourceFolder;C;ns;opCode;filename
2+
⍝ Test the global config parameter "HandleLinkStops"
3+
⍝ *** Note that this function temporarily replaces Cider's global config file!
4+
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
5+
6+
name←⊃⎕SI
7+
globalConfig←##.Cider.GetCiderGlobalConfigFilename
8+
'Left-over from earlier test case?! Needs to be resoved!'Assert 0=⎕NEXISTS(globalConfig,'.bkp')
9+
(globalConfig,'.bkp')⎕NMOVE globalConfig ⍝ Save Cider's original global config file
10+
ns←⎕NS''
11+
ns.HandleLinkStops←0
12+
∆SaveCiderGlobalConfig ns
13+
sourceFolder←##.CiderConfig.HOME,'/TestData/Link.Config'
14+
targetFolder←∆GetFolderInTempDir name
15+
filename←targetFolder,'/.linkconfig'
16+
filename ⎕NCOPY sourceFolder,'/.linkconfig-1' ⍝ Contains stops and "watch" parameter
17+
C←∆GetRefToCommTools
18+
C.AddAutomation'YesOrNo' 'StopsAndTraces@' 'y'
19+
20+
→T.GoToTidyUp 0≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
21+
→T.GoToTidyUp 1≠⎕NEXISTS filename
22+
23+
ns.HandleLinkStops←1
24+
∆SaveCiderGlobalConfig ns
25+
→T.GoToTidyUp 2≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
26+
→T.GoToTidyUp 1≠⎕NEXISTS filename
27+
28+
ns.HandleLinkStops←2
29+
∆SaveCiderGlobalConfig ns
30+
→T.GoToTidyUp 2≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
31+
→T.GoToTidyUp 1≠⎕NEXISTS filename
32+
33+
r←T._OK
34+
35+
∆TidyUp:
36+
⎕NDELETE globalConfig
37+
globalConfig ⎕NMOVE globalConfig,'.bkp' ⍝ Restore original
38+
C.Cleanup
39+
(rc en msg)←FilesAndDirs.RmDir targetFolder
40+
msg Assert rc=0
41+
⍝Done
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
r←Test_Misc_021(stopFlag batchFlag);⎕TRAP;name;rc;en;msg;globalConfig;targetFolder;sourceFolder;C;ns;opCode;filename
2+
⍝ Test the global config parameter "HandleLinkStops"
3+
⍝ *** Note that this function temporarily replaces Cider's global config file!
4+
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
5+
6+
name←⊃⎕SI
7+
globalConfig←##.Cider.GetCiderGlobalConfigFilename
8+
'Left-over from earlier test case?! Needs to be resoved!'Assert 0=⎕NEXISTS(globalConfig,'.bkp')
9+
(globalConfig,'.bkp')⎕NMOVE globalConfig ⍝ Save Cider's original global config file
10+
ns←⎕NS''
11+
ns.HandleLinkStops←0
12+
∆SaveCiderGlobalConfig ns
13+
sourceFolder←##.CiderConfig.HOME,'/TestData/Link.Config'
14+
targetFolder←∆GetFolderInTempDir name
15+
filename←targetFolder,'/.linkconfig'
16+
filename ⎕NCOPY sourceFolder,'/.linkconfig-2' ⍝ Contains stops but no parameter
17+
C←∆GetRefToCommTools
18+
C.AddAutomation'YesOrNo' 'StopsAndTraces@' 'y'
19+
20+
→T.GoToTidyUp 0≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
21+
→T.GoToTidyUp 1≠⎕NEXISTS filename
22+
23+
ns.HandleLinkStops←1
24+
∆SaveCiderGlobalConfig ns
25+
→T.GoToTidyUp 1≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
26+
→T.GoToTidyUp 0≠⎕NEXISTS filename
27+
28+
filename ⎕NCOPY sourceFolder,'/.linkconfig-2' ⍝ Contains stops but no parameter
29+
C.Cleanup
30+
ns.HandleLinkStops←2
31+
∆SaveCiderGlobalConfig ns
32+
→T.GoToTidyUp 1≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
33+
→T.GoToTidyUp 0≠⎕NEXISTS filename
34+
35+
r←T._OK
36+
37+
∆TidyUp:
38+
⎕NDELETE globalConfig
39+
globalConfig ⎕NMOVE globalConfig,'.bkp' ⍝ Restore original
40+
C.Cleanup
41+
(rc en msg)←FilesAndDirs.RmDir targetFolder
42+
msg Assert rc=0
43+
⍝Done
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
r←Test_Misc_022(stopFlag batchFlag);⎕TRAP;name;rc;en;msg;globalConfig;targetFolder;sourceFolder;C;ns;opCode;filename
2+
⍝ Test the global config parameter "HandleLinkStops"
3+
⍝ *** Note that this function temporarily replaces Cider's global config file!
4+
⎕TRAP←(999 'C' '. ⍝ Deliberate error')(0 'N')
5+
6+
name←⊃⎕SI
7+
globalConfig←##.Cider.GetCiderGlobalConfigFilename
8+
'Left-over from earlier test case?! Needs to be resoved!'Assert 0=⎕NEXISTS(globalConfig,'.bkp')
9+
(globalConfig,'.bkp')⎕NMOVE globalConfig ⍝ Save Cider's original global config file
10+
ns←⎕NS''
11+
ns.HandleLinkStops←0
12+
∆SaveCiderGlobalConfig ns
13+
sourceFolder←##.CiderConfig.HOME,'/TestData/Link.Config'
14+
targetFolder←∆GetFolderInTempDir name
15+
filename←targetFolder,'/.linkconfig'
16+
filename ⎕NCOPY sourceFolder,'/.linkconfig-3' ⍝ Contains "watch" parameter but no stops
17+
C←∆GetRefToCommTools
18+
C.AddAutomation'YesOrNo' 'StopsAndTraces@' 'y'
19+
20+
→T.GoToTidyUp 0≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
21+
→T.GoToTidyUp 1≠⎕NEXISTS filename
22+
23+
ns.HandleLinkStops←1
24+
∆SaveCiderGlobalConfig ns
25+
→T.GoToTidyUp 0≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
26+
→T.GoToTidyUp 1≠⎕NEXISTS filename
27+
28+
ns.HandleLinkStops←2
29+
∆SaveCiderGlobalConfig ns
30+
→T.GoToTidyUp 0≠opCode←##.Cider.HandleLinkSourceFlags targetFolder
31+
→T.GoToTidyUp 1≠⎕NEXISTS filename
32+
33+
r←T._OK
34+
35+
∆TidyUp:
36+
⎕NDELETE globalConfig
37+
globalConfig ⎕NMOVE globalConfig,'.bkp' ⍝ Restore original
38+
C.Cleanup
39+
(rc en msg)←FilesAndDirs.RmDir targetFolder
40+
msg Assert rc=0
41+
⍝Done
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
∆SaveCiderGlobalConfig ns;filename;json
2+
filename←##.Cider.GetCiderGlobalConfigFilename
3+
json←⎕JSON⍠('Dialect' 'JSON5')('Compact' 0)⊣ns
4+
(⊂json)⎕NPUT filename 1

0 commit comments

Comments
 (0)