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

add NO_UNDO flags to all regions #2370

Merged
merged 12 commits into from
Dec 13, 2023
Merged

add NO_UNDO flags to all regions #2370

merged 12 commits into from
Dec 13, 2023

Conversation

rchl
Copy link
Member

@rchl rchl commented Dec 4, 2023

Added NO_UNDO flag to all (?) add_regions calls. I have not really battle tested it yet so intending to spend some time doing that and checking whether there are any downsides.

Resolves #2359

plugin/core/views.py Outdated Show resolved Hide resolved
@predragnikolic
Copy link
Member

I will start testing this

@jwortmann
Copy link
Member

jwortmann commented Dec 9, 2023

I wonder is there any reason why NO_UNDO was not added when drawing the regions in

def _initialize_region_keys(self) -> None:

I doubt that there is a measurable performance difference from doing that, because those regions are drawn only a single time for each view, but it probably also doesn't hurt to add the flag. So I would add it just for consistency. And then I would probably also add the HIDDEN flag, which in this case doesn't have any effect because the regions are empty anyway, but it feels more correct to have it and it might make the code a bit more comprehensible.

Perhaps NO_UNDO is implied anyway when the HIDDEN flag is set, but I guess explicit is better than implicit ;-)
Also maybe this already answers the question above and NO_UNDO is implied for empty regions in general, but I wouldn't count on that and we don't know how ST manages its undo history internally.

For example

REGIONS_INITIALIZE_FLAGS = sublime.HIDDEN | sublime.NO_UNDO 

(haven't tested though)

@rchl
Copy link
Member Author

rchl commented Dec 10, 2023

Seeing decent memory savings on this branch.

This is tested on the typescript-language-server repo with 10 different files opened showing semantic tokens and code lens annotations.

The physical session file doesn't seem to be affected much. Which I guess makes sense because those regions don't survive restart so those are only stored in memory.

Before

Screenshot 2023-12-10 at 21 11 24

After

Screenshot 2023-12-10 at 21 10 36

@predragnikolic
Copy link
Member

I haven't noticed any issues with this.

@rchl rchl merged commit 97b5558 into main Dec 13, 2023
4 checks passed
@rchl rchl deleted the fix/no-undo branch December 13, 2023 11:38
rchl added a commit that referenced this pull request Dec 13, 2023
* main:
  add NO_UNDO flags to all regions (#2370)
  Fix some mypy type issues in stubs (#2374)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate using NO_UNDO flag for regions
3 participants