Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Limit text ripping in "rename symbol" function (F2) or "change all occurences" function (Ctrl+F2) #99651

Closed
FALLAI-Denis opened this issue Jun 9, 2020 · 5 comments
Assignees
Labels
feature-request Request for new features or functionality

Comments

@FALLAI-Denis
Copy link

FALLAI-Denis commented Jun 9, 2020

When a symbol is renamed, or a text is changed, with a shorter or longer name, or text, this causes all the text placed to its right to be shifted either to the left if the new name, or text, is shorter than the old one, or to the right if the new name, or text, is longer than the old one.

If the text of several lines has been aligned, or if we use a programming language which requires placing the text in precise locations (we use Cobol and Assembler for a mainframe platform), these shifts no longer respect the alignments implemented, or for languages which require respecting positions this can lead to compilation errors.

We propose that an "intelligent" shift system be implemented:

  • if the new symbol name, or new text, is shorter than the old one, the text placed to its right is shifted to the left until a sequence of at least 2 spaces is encountered, from this point no shift of text is done to the left
  • if the new symbol name, or new text, is longer than the old one, the text placed to its right is shifted to the right, reducing the number of spaces to keep only 1 until it is no longer need to shift right, that is, the existing text can remain in its position.

In order not to create a problem with the current behavior, this function could be controlled by a new option, which should be able to be associated with a language mode. This options would specify the minimum number of spaces to keep during text shifts in the event of renaming of symbols or replacing text.

Example: limit compression of spaces to only 1 (or n) space, expand spaces as soon as more than 1 (or n) space

"[langueid]": {
  "editor.smartshift": 1
  }

A value of 0 would disable the functionality.

Use case:

Starting state
SmartShift01

Rename symbol "MIDDLE-NAME" to "AHAH"
SmartShift02
the new symbol is shorter, the text is shifted to the left: the text is no longer aligned and the area in column 73 is shifted to the left which would trigger a compilation error.

Expected result:
SmartShift03

Rename symbol "SHORNAME" to "A-LONGER-NAME"
SmartShift04
the new name is longer, the text is shifted to the right: the text is no longer aligned and the area in column 73 is shifted to the right which would trigger a compilation error.

Expected result:
SmartShift05

@jrieken jrieken added this to the Backlog Candidates milestone Jun 9, 2020
@jrieken jrieken added the feature-request Request for new features or functionality label Jun 9, 2020
@jrieken
Copy link
Member

jrieken commented Jun 9, 2020

TBH I think there is low chances that vs code itself will support this. To me this seems like a perfect use-case for a COBOL formatter extension which is doing these kind of things. Or a source code action which is making this alignment "fixes"

@FALLAI-Denis
Copy link
Author

FALLAI-Denis commented Jun 9, 2020

Thanks for your feedback.

I think that the functionality does not only concern the "columned" languages inherited from the 80 column card format.
It can also concern more "modern" languages: the search and replace functions must keep the alignments that the developer has been able to set up to facilitate the reading of his code.
What identifies the presence of an alignment is the fact that several spaces (or tabulations) are present between words of the same line.
This can also concern data files.

Cobol rules the world !

Regardless of the functionality requested, there is a large, but probably less visible, population of mainframe developers looking for tools, and the companies that use them looking to federate different development teams on the same tools.

It is estimated that there are between 200 and 250 billion lines of Cobol code running worldwide, and that 5 billion new lines of Cobol code are created each year by 1 million Cobol programmers.
This code corresponds to systemic companies which are essential to the economy of countries and therefore of the world: banks, insurance, a large part of trade. This would represent the treatment of 3 trillion dollars each year.
It is time for this heritage and for this population to have modern tools, otherwise it will be the obsolescence of these systems with fairly disastrous consequences.

Some information available here: http://cobolcowboys.com/cobol-today/

@github-actions github-actions bot locked and limited conversation to collaborators Sep 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

3 participants
@jrieken @FALLAI-Denis and others