TypeCobol icon indicating copy to clipboard operation
TypeCobol copied to clipboard

During a replace the Scanner always use ColumnsLayout.FreeTextFormat

Open smedilol opened this issue 2 years ago • 0 comments

Describe the bug LINK WITH #2218 During a replace the Scanner always use ColumnsLayout.FreeTextFormat. See method ScanIsolatedToken in the Scanner. And the line TokensLine.CreateVirtualLineForInsertedToken(0, tokenText);

The ScanState used by ScanIsolatedToken is correct and is the ScanState of the original token. But the ScanState doesn't have the information of the ColumnsLayout.

To Reproduce Cobol code that cause the bug :

       IDENTIFICATION DIVISION.
       PROGRAM-ID. MyPgm.
       procedure division.
      
       REPLACE ==:-MAJ:== BY ====.
           PERFORM EACGAPEL-C0001:-MAJ:.
           .
       END PROGRAM MyPgm.

Expected behavior ScanIsolatedToken must use the correct ColumnsLayout.

Technical Suggestion: Pass argument of type ColumnsLayout to method ScanIsolatedToken. ColumnsLayout could be exposed by ICobolTextLine, so the value could be retrieve by the caller of ScanIsolatedToken.

How to test automatically We need a test in the Scanner that rely on the ColumnsLayout. Maybe a simple test like tokensLine.ColumnsLayout == ColumnsLayout.CobolReferenceFormat && tokensLine.Text.Length > 80 already in the Scanner but to check a whole line.

smedilol avatar Apr 22 '22 12:04 smedilol