Added per provider cursor position for the Pattern editor. #1861
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem description
Currently, the pattern editor does not remember where the cursor is located in each provider. For example, suppose you have 2 providers in your project, and you scrolled down to line 200 in the first pattern to make some changes and remembered that the code you want to insert is in the second provider. Then you switch to the second provider, look for the code and find it in line 235. Switch back to the first one, and you are at the beginning of the file. So you again look for the line to edit paste it to realize that it needs code a few lines before the place you found it. You switch to the second provider, and you are at the top again. This gets annoying very fast.
Implementation description
This PR ensures that, when you return to the pattern in the editor for any of the opened providers, the cursor will still be at the same place it was when you switched to a different one. Each provider pattern saves its cursor position and returns to it when you switch to that provider. It does that by creating a PerProvider variable and using it when providers are first opened to set it to the origin and when switching providers it first saves the position of the old provider and then loads and sets the saved position of the new provider.