Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Synchronize text buffer access - #1479

Merged
Mikhail Arkhipov (MikhailArkhipov) merged 6 commits into
microsoft:masterfrom
MikhailArkhipov:desync
Aug 26, 2019
Merged

Mikhail Arkhipov (MikhailArkhipov) merged 6 commits into
microsoft:masterfrom
MikhailArkhipov:desync

Conversation

@MikhailArkhipov

@MikhailArkhipov Mikhail Arkhipov (MikhailArkhipov) commented Aug 24, 2019 •

Copy link
Copy Markdown

Fixes #1466
Fixes #1449
Fixes #1425
Fixes #1353

Although text buffer updates come from the same thread, it does can be read concurrently by the analysis and Reset can be called as well (although this is probably extremely rare as we do not call Reset on user files when analysis completes).

Call for content by the parser or analyzer may cause conversion of the string builder to _content in the middle of the string builder update yielding odd partial results.

public string Text {
get {
lock (_lock) {
return _content ?? (_content = _sb?.ToString() ?? string.Empty);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the case when _content == null and _sb == null?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically when something calls Text before initial Update

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

However, we can just create _sb at construction time for simplicity

@haollhao

Copy link
Copy Markdown

I am using the latest version of the extension (2019.9.34911) and the synchronization problem still exists.

@MikhailArkhipov

Copy link
Copy Markdown
Author

LS version is unrelated to the extension version and is not tied to it. Which LS version do you see in the output? Something like 0.3.x or 0.4.x

@jakebailey

Copy link
Copy Markdown
Member

Please open an issue with your problem and the information we request in the template; if this PR didn't fix your issue, then it may be something else.

Note that the extension version is not the language server version. They are versioned separately.

Jake Bailey (jakebailey) pushed a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
* Synchronize text buffer

* Simplify

* One more

* Use ??

* Typo

* Simplify
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

4 participants