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

[Property Editor] Handle null text document / text document version in ActiveLocationChangedEvent #8781

Merged
merged 3 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class ActiveLocationChangedEvent extends EditorEvent {
);

final List<EditorSelection> selections;
final TextDocument textDocument;
final TextDocument? textDocument;

@override
EditorEventKind get kind => EditorEventKind.activeLocationChanged;
Expand All @@ -341,11 +341,11 @@ class TextDocument with Serializable {
TextDocument.fromJson(Map<String, Object?> map)
: this(
uriAsString: map[Field.uri] as String,
version: map[Field.version] as int,
version: map[Field.version] as int?,
);

final String uriAsString;
final int version;
final int? version;

@override
Map<String, Object?> toJson() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ class PropertyEditorController extends DisposableController
editorClient.activeLocationChangedStream.listen((event) async {
final textDocument = event.textDocument;
final cursorPosition = event.selections.first.active;
// Don't do anything if the text document is null.
if (textDocument == null) {
return;
}
// Don't do anything if the event corresponds to the current position.
if (textDocument == _currentDocument &&
cursorPosition == _currentCursorPosition) {
Expand Down
Loading