-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Wrap code editor for template selector #21104
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -47,6 +47,8 @@ export class HaCodeEditor extends ReactiveElement { | |||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
@property({ type: Boolean }) public readOnly = false; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
@property({ type: Boolean }) public linewrap = false; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
@property({ type: Boolean, attribute: "autocomplete-entities" }) | ||||||||||||||||||||||||||||||
public autocompleteEntities = false; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
@@ -134,6 +136,13 @@ export class HaCodeEditor extends ReactiveElement { | |||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
if (changedProps.has("linewrap")) { | ||||||||||||||||||||||||||||||
transactions.push({ | ||||||||||||||||||||||||||||||
effects: this._loadedCodeMirror!.linewrapCompartment!.reconfigure( | ||||||||||||||||||||||||||||||
this.linewrap ? this._loadedCodeMirror!.EditorView.lineWrapping : [] | ||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||
}); | ||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||
Comment on lines
+139
to
+145
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure the use of non-null assertions is safe here. - this._loadedCodeMirror!.linewrapCompartment!.reconfigure(
+ this._loadedCodeMirror?.linewrapCompartment?.reconfigure( The non-null assertion operator ( Committable suggestion
Suggested change
ToolsBiome
|
||||||||||||||||||||||||||||||
if (changedProps.has("_value") && this._value !== this.value) { | ||||||||||||||||||||||||||||||
transactions.push({ | ||||||||||||||||||||||||||||||
changes: { | ||||||||||||||||||||||||||||||
|
@@ -181,6 +190,9 @@ export class HaCodeEditor extends ReactiveElement { | |||||||||||||||||||||||||||||
this._loadedCodeMirror.readonlyCompartment.of( | ||||||||||||||||||||||||||||||
this._loadedCodeMirror.EditorView.editable.of(!this.readOnly) | ||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||
this._loadedCodeMirror.linewrapCompartment.of( | ||||||||||||||||||||||||||||||
this.linewrap ? this._loadedCodeMirror.EditorView.lineWrapping : [] | ||||||||||||||||||||||||||||||
), | ||||||||||||||||||||||||||||||
Comment on lines
+193
to
+195
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ensure the use of non-null assertions is safe here. - this._loadedCodeMirror!.linewrapCompartment!.of(
+ this._loadedCodeMirror?.linewrapCompartment?.of( As previously noted, using non-null assertions without checks can lead to runtime issues. Optional chaining should be used instead to ensure the code is robust against null values. Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||
this._loadedCodeMirror.EditorView.updateListener.of(this._onUpdate), | ||||||||||||||||||||||||||||||
]; | ||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a brief comment describing the purpose of the
linewrap
property.Adding a comment above this property will improve code readability and maintainability, helping future developers understand its use more quickly.