Fix syntax validator

This commit is contained in:
1024jp 2023-12-29 23:16:49 +09:00
parent 6715f67b7f
commit e4d40bb29d
2 changed files with 9 additions and 3 deletions

View File

@ -12,6 +12,7 @@
### Fixes
- Fix an issue that the application could not open a document containing a specific pattern of letters.
- Fix an issue that the validation error message in the syntax editor did not change even when errors were found.

View File

@ -30,6 +30,7 @@ struct SyntaxValidationView: View {
let validator: SyntaxValidator
@State private var errors: [SyntaxValidator.Error] = []
@State private var selection: Int?
// MARK: View
@ -38,7 +39,7 @@ struct SyntaxValidationView: View {
VStack(alignment: .leading) {
MessageView(count: self.errors.count)
List(Array(self.errors.enumerated()), id: \.offset) { (_, error) in
List(Array(self.errors.enumerated()), id: \.offset, selection: $selection) { (_, error) in
ErrorView(error: error)
}
}
@ -56,7 +57,7 @@ struct SyntaxValidationView: View {
private struct MessageView: View {
@State var count: Int
var count: Int
var body: some View {
@ -105,7 +106,6 @@ struct SyntaxValidationView: View {
.controlSize(.small)
}
}
.foregroundColor(.label)
.textSelection(.enabled)
} icon: {
Image(systemName: "exclamationmark.triangle")
@ -132,3 +132,8 @@ struct SyntaxValidationView: View {
return SyntaxValidationView(validator: .init(syntax: syntax))
.frame(width: 400)
}
#Preview("No Error") {
SyntaxValidationView(validator: .init(syntax: [:]))
.frame(width: 400)
}