IBM / zopeneditor-about

IBM Z Open Editor: File issues here!
https://ibm.github.io/zopeneditor-about
Apache License 2.0
47 stars 25 forks source link

Enable unnumber function for other files #334

Open Rune-Christensen opened 1 year ago

Rune-Christensen commented 1 year ago

Description of the enhancement requested

As user of COBOL Check, we have unit test files located on Z, with line numbers. I would like to be able to remove these line numbers, using the unnumber command. So I can save my unit test files in BitBucket, without line numbers.

Notes: Currently when I open a unit test file in VSCode, Z Open Editor does not enable the unnumber command. I have tried forcing a call to the command, but the unnumbering command does not work. I believe there is some code in the unnumber command, that checks for the type of file the command is called in. Is it possible to move that file type check into the WHEN part of the command definition, then I can overwrite the WHEN part, and enable the command for the type of file I want to.

phaumer commented 1 year ago

@Rune-Christensen can you provide the steps and perhaps a sample file. Would just changing the file extension or adding the file extension to the user settings be a workaround?

Rune-Christensen commented 1 year ago

Hi @phaumer We have added a hook in our own extension, to run unnumber when opening COBOL and COBOL Check files:

    vscode.window.onDidChangeActiveTextEditor((editor) => {     
        if (editor && (verifyCobolFile(editor.document.fileName, true)  || VerifyCobolUnitTestFile(editor.document.fileName))) {
            vscode.commands.executeCommand('cobol.unnumber');
        }
    });

This automatically runs unnumber when entering a COBOL or unit test file. Just using the editor, any other file, not registered as COBOL, (or PL/1, Rexx or Assembly) will not enable us to run unnumber.

There are two scenarios:

  1. Using Zowe explorer, we open a member, in a directory, that is not registered as a COBOL directory, but as a COBOL Check directory.
  2. Opening a file, with the extension .cut (or any other not registered as COBOL)

Or for that matter, any other file, not registered as COBOL, but containing line numbers.

Yes, changing the file extension or registering the directory differently, is a workaround, but, we consider that adding technical debt to our setup. This is because we would have to change the file name or registration back to unit test, after running unnumber, to get COBOL Check to register the file as a unit test file. Otherwise we wont be able to run the tests, or use the linter for those files.

Examples of COBOL Check test files, can be found in the repository: https://github.com/openmainframeproject/cobol-check/tree/Developer/src/test/cobol

FALLAI-Denis commented 1 year ago

Hi @Rune-Christensen,

Same as Allways unnumber my code.

Consider an extension like Regex Replace on Save.