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

Finish the package: Fix Project Switch-Restart Bug #26

Closed
evandrocoan opened this issue Nov 22, 2016 · 3 comments
Closed

Finish the package: Fix Project Switch-Restart Bug #26

evandrocoan opened this issue Nov 22, 2016 · 3 comments

Comments

@evandrocoan
Copy link
Owner

evandrocoan commented Nov 22, 2016

Finish the package: Fix Project Switch-Restart Bug

It partially fix the issues:

  1. SublimeTextIssues#1379 Restore session, does not set the last scroll position after a project change, or sublime restart
  2. titoBouzout#23 Scroll sync doesn't work (ST3 3084)

To accomplish it, it move the caret up and down, this way it forces the scroll view to be switched.
This causes the undesired behavior when switching views after the file being loaded or the
project being restored.

To fix this problems, just to perform those operations when the file is loaded for the first time.
This is a problem when Sublime Text just starts because this package is not loaded yet. This way
we need to perform this action at the first time the file is chose/switched to.

I am thinking about to use the forward on_plugin_loaded to perform a for all views, this way I can still use only the forward on_loadto fix the issue postSublime Text` start and keep the scroll issue when switching views.

evandrocoan added a commit that referenced this issue Nov 22, 2016
Issues:

Finish the package: Fix Project Switch-Restart Bug
#26

Restore session, does not set the last scroll position after a
project change, or sublime restart #1379
sublimehq/sublime_text#1379

Scroll sync doesn't work (ST3 3084)
https://github.com/titoBouzout/BufferScroll/issues/23

To accomplish it, it move the caret up and down, this way it forces
the scroll view to be switched. This causes the undesired behavior
when switching views after the file being loaded or the project
being restored.

To fix this problems, just on to perform those operations when the
file is loaded for the first time. This is a problem when Sublime
Text just starts because this package is not loaded yet. This way
we need to perform this action at the first time the file is
chose/switched to.
evandrocoan added a commit that referenced this issue Nov 22, 2016
#26

First part implementation. Now remains to replace:
```
        view.run_command( "move", {"by": "lines", "forward": False} )
        view.run_command( "move", {"by": "lines", "forward": True} )
```
By a actual command to change the view to the current cursor
centered position.
@evandrocoan
Copy link
Owner Author

evandrocoan commented Nov 22, 2016

Finished the first part implementation. Now remains to replace:

        view.run_command( "move", {"by": "lines", "forward": False} )
        view.run_command( "move", {"by": "lines", "forward": True} )

By a actual command to change the view to the current cursor
centered position and re-enable the setting "scroll_past_end": true,.


Seconds step is to catch the change project command, and make the are_we_on_the_project_switch_process() return True. And when the project change is complete, make the are_we_on_the_project_switch_process return False and call the plugin_loaded() to fix the views scroll positions.

import sublime
import sublime_plugin

class SampleListener(sublime_plugin.EventListener):
    def on_window_command(self, window, command, args):
        if command == "edit_settings":
            print ("About to execute " + command)

    def on_post_window_command(self, window, command, args):
        if command == "edit_settings":
            print ("Finished executing " + command)

https://forum.sublimetext.com/t/how-to-hook-the-new-show-settings-event/23793/2

    {
        "caption": "Project",
        "id": "project",
        "mnemonic": "P",
        "children":
        [
            { "command": "prompt_open_project_or_workspace", "caption": "Open Project…" },
            { "command": "prompt_switch_project_or_workspace", "caption": "Switch Project…" },
            { "command": "prompt_select_workspace", "caption": "Quick Switch Project…", "mnemonic": "S" },
            {
                "caption": "Open Recent",
                "children":
                [
                    { "command": "open_recent_project_or_workspace", "args": {"index": 0 } },
                    { "command": "open_recent_project_or_workspace", "args": {"index": 1 } },
                    { "command": "open_recent_project_or_workspace", "args": {"index": 2 } },
                    { "command": "open_recent_project_or_workspace", "args": {"index": 3 } },
                    { "command": "open_recent_project_or_workspace", "args": {"index": 4 } },
                    { "command": "open_recent_project_or_workspace", "args": {"index": 5 } },
                    { "command": "open_recent_project_or_workspace", "args": {"index": 6 } },
                    { "command": "open_recent_project_or_workspace", "args": {"index": 7 } },
                    { "caption": "-" },
                    { "command": "clear_recent_projects_and_workspaces", "caption": "Clear Items" }
                ]
            },

@evandrocoan
Copy link
Owner Author

This temporary fix is a priori concluded. It only down side is when opening a new window, not all cloned view will not be properly set due the bug:

  1. Event handlers for cloned views get called with the wrong view object sublimehq/sublime_text#1253 Event handlers for cloned views get called with the wrong view object

The commit shows this stated state functionality:

  1. https://github.com/evandrocoan/SublimeTextStudio/tree/f96b112d7d6f8f86c39812b4dc2d4e79673bb975/Fix%20Project%20Switch-Restart%20Bug

@evandrocoan evandrocoan reopened this Nov 27, 2016
evandrocoan added a commit to evandrocoan/.versioning that referenced this issue Nov 27, 2016
Issues:

Finish the package: Fix Project Switch-Restart Bug
evandrocoan/ITE#26

Restore session, does not set the last scroll position after a
project change, or sublime restart #1379
sublimehq/sublime_text#1379

Scroll sync doesn't work (ST3 3084)
https://github.com/titoBouzout/BufferScroll/issues/23

To accomplish it, it move the caret up and down, this way it forces
the scroll view to be switched. This causes the undesired behavior
when switching views after the file being loaded or the project
being restored.

To fix this problems, just on to perform those operations when the
file is loaded for the first time. This is a problem when Sublime
Text just starts because this package is not loaded yet. This way
we need to perform this action at the first time the file is
chose/switched to.
evandrocoan added a commit to evandrocoan/.versioning that referenced this issue Nov 27, 2016
evandrocoan/ITE#26

First part implementation. Now remains to replace:
```
        view.run_command( "move", {"by": "lines", "forward": False} )
        view.run_command( "move", {"by": "lines", "forward": True} )
```
By a actual command to change the view to the current cursor
centered position.
evandrocoan added a commit to evandrocoan/.versioning that referenced this issue Nov 27, 2016
Issues:

Finish the package: Fix Project Switch-Restart Bug
evandrocoan/ITE#26

Restore session, does not set the last scroll position after a
project change, or sublime restart #1379
sublimehq/sublime_text#1379

Scroll sync doesn't work (ST3 3084)
https://github.com/titoBouzout/BufferScroll/issues/23

To accomplish it, it move the caret up and down, this way it forces
the scroll view to be switched. This causes the undesired behavior
when switching views after the file being loaded or the project
being restored.

To fix this problems, just on to perform those operations when the
file is loaded for the first time. This is a problem when Sublime
Text just starts because this package is not loaded yet. This way
we need to perform this action at the first time the file is
chose/switched to.
evandrocoan added a commit to evandrocoan/.versioning that referenced this issue Nov 27, 2016
evandrocoan/ITE#26

First part implementation. Now remains to replace:
```
        view.run_command( "move", {"by": "lines", "forward": False} )
        view.run_command( "move", {"by": "lines", "forward": True} )
```
By a actual command to change the view to the current cursor
centered position.
evandrocoan added a commit that referenced this issue Jun 19, 2017
Issues:

Finish the package: Fix Project Switch-Restart Bug
#26

Restore session, does not set the last scroll position after a
project change, or sublime restart #1379
sublimehq/sublime_text#1379

Scroll sync doesn't work (ST3 3084)
https://github.com/titoBouzout/BufferScroll/issues/23

To accomplish it, it move the caret up and down, this way it forces
the scroll view to be switched. This causes the undesired behavior
when switching views after the file being loaded or the project
being restored.

To fix this problems, just on to perform those operations when the
file is loaded for the first time. This is a problem when Sublime
Text just starts because this package is not loaded yet. This way
we need to perform this action at the first time the file is
chose/switched to.
evandrocoan added a commit that referenced this issue Jun 19, 2017
#26

First part implementation. Now remains to replace:
```
        view.run_command( "move", {"by": "lines", "forward": False} )
        view.run_command( "move", {"by": "lines", "forward": True} )
```
By a actual command to change the view to the current cursor
centered position.
@evandrocoan
Copy link
Owner Author

The fix package is already completed, then this can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant