diff options
| author | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-15 00:11:21 +0100 |
|---|---|---|
| committer | Ruben Beltran del Rio <jj@r.bdr.sh> | 2025-12-15 00:19:39 +0100 |
| commit | fa681bfcf5cbfcc711fb0ab10f3fd74ac83bf18c (patch) | |
| tree | 2dce2e95bab08f773246b450ac50227f8e8f57da | |
| parent | 0d5e6636405dbe332c33c0fb82c7ccccb20f96cb (diff) | |
Apply formatting rules
27 files changed, 92 insertions, 95 deletions
@@ -40,9 +40,10 @@ prepare: @mkdir -p $(build_directory) format: - @swift format -i -r . + swift-format --in-place --recursive Map MapTests + swiftlint --fix Map MapTests lint: - @swift format lint -r . + @swiftlint Map MapTests .PHONY: package prepare archive generate_appcast package distribute format lint build test notarize sign_distributable upload repackage diff --git a/Map/Business/RenderableMap.swift b/Map/Business/RenderableMap.swift index 82acaff..eeddb8b 100644 --- a/Map/Business/RenderableMap.swift +++ b/Map/Business/RenderableMap.swift @@ -39,18 +39,19 @@ struct RenderableMap { // Build a vertex lookup for edges, groups, etc. var vertexMap: [String: Vertex] = [:] - + for (index, component) in map.components.enumerated() { let newVertex = Vertex( id: index, label: component.label, - position: CGPoint(x: component.coordinates.xCoordinate, y: component.coordinates.yCoordinate), + position: CGPoint( + x: component.coordinates.xCoordinate, y: component.coordinates.yCoordinate), shape: component.shape ) vertices.append(newVertex) vertexMap[component.label.lowercased()] = newVertex } - + for (index, note) in map.notes.enumerated() { notes.append( Note( @@ -70,8 +71,7 @@ struct RenderableMap { // Second pass for entities that depend on vertices for (index, dependency) in map.dependencies.enumerated() { if let fromVertex = vertexMap[dependency.fromComponent.lowercased()], - let toVertex = vertexMap[dependency.toComponent.lowercased()] - { + let toVertex = vertexMap[dependency.toComponent.lowercased()] { edges.append( MapEdge( id: index, @@ -81,7 +81,7 @@ struct RenderableMap { )) } } - + for (index, inertia) in map.inertias.enumerated() { if let vertex = vertexMap[inertia.component.lowercased()] { inertias.append( @@ -91,7 +91,7 @@ struct RenderableMap { )) } } - + for (index, evolution) in map.evolutions.enumerated() { if let vertex = vertexMap[evolution.component.lowercased()] { let destination = CGPoint( @@ -106,7 +106,7 @@ struct RenderableMap { )) } } - + for group in map.groups { var groupVertices: [Vertex] = [] for componentName in group.components { @@ -174,5 +174,5 @@ struct Opportunity { private let defaultDimensions: [Double] = [ 25.0, 50.0, - 75.0, + 75.0 ] diff --git a/Map/Business/SmartLabelPositioning/SmartLabelPositioning.swift b/Map/Business/SmartLabelPositioning/SmartLabelPositioning.swift index f765108..edf22e3 100644 --- a/Map/Business/SmartLabelPositioning/SmartLabelPositioning.swift +++ b/Map/Business/SmartLabelPositioning/SmartLabelPositioning.swift @@ -59,8 +59,7 @@ struct SmartLabelPositioning { let defaultRect = CGRect(origin: defaultPosition, size: actualLabelSize) if countCollisions(labelRect: defaultRect, lines: allLines) == 0 - && countNoteCollisions(labelRect: defaultRect, noteRects: noteRects) == 0 - { + && countNoteCollisions(labelRect: defaultRect, noteRects: noteRects) == 0 { return defaultPosition } @@ -204,7 +203,7 @@ struct SmartLabelPositioning { CGPoint( x: vertexPixelPos.x - labelSize.width - padding, y: vertexPixelPos.y + vertexSize.height + padding - ), + ) ] } @@ -301,7 +300,7 @@ struct SmartLabelPositioning { Line(start: CGPoint(x: rect.minX, y: rect.minY), end: CGPoint(x: rect.maxX, y: rect.minY)), Line(start: CGPoint(x: rect.maxX, y: rect.minY), end: CGPoint(x: rect.maxX, y: rect.maxY)), Line(start: CGPoint(x: rect.maxX, y: rect.maxY), end: CGPoint(x: rect.minX, y: rect.maxY)), - Line(start: CGPoint(x: rect.minX, y: rect.maxY), end: CGPoint(x: rect.minX, y: rect.minY)), + Line(start: CGPoint(x: rect.minX, y: rect.maxY), end: CGPoint(x: rect.minX, y: rect.minY)) ] for rectLine in rectLines { diff --git a/Map/Business/Stage.swift b/Map/Business/Stage.swift index ebee17f..4962f8f 100644 --- a/Map/Business/Stage.swift +++ b/Map/Business/Stage.swift @@ -153,8 +153,7 @@ struct Stage: Codable { if let customStagesData = UserDefaults.standard.data(forKey: "customStages"), let customStagesList = try? JSONDecoder().decode( [CustomStage].self, from: customStagesData), - let customStage = customStagesList.first(where: { $0.id == uuid }) - { + let customStage = customStagesList.first(where: { $0.id == uuid }) { return customStage.stage } return stages(.behavior) // fallback @@ -207,8 +206,7 @@ struct Stage: Codable { if let customStagesData = UserDefaults.standard.data(forKey: "customStages"), let customStagesList = try? JSONDecoder().decode( [CustomStage].self, from: customStagesData), - let customStage = customStagesList.first(where: { $0.id == uuid }) - { + let customStage = customStagesList.first(where: { $0.id == uuid }) { return customStage.name } return String(localized: "stage_type.behavior") // fallback @@ -273,13 +271,12 @@ enum StageType: Identifiable, Equatable { static let properties: [StageType] = [ .market, .knowledgeManagement, .marketPerception, .userPerception, .perceptionInIndustry, .focusOfValue, .understanding, .comparison, .failure, - .marketAction, .efficiency, .decisionDrivers, + .marketAction, .efficiency, .decisionDrivers ] static var customStages: [StageType] { if let customStagesData = UserDefaults.standard.data(forKey: "customStages"), - let customStagesList = try? JSONDecoder().decode([CustomStage].self, from: customStagesData) - { + let customStagesList = try? JSONDecoder().decode([CustomStage].self, from: customStagesData) { return customStagesList.map { .custom($0.id) } } return [] diff --git a/Map/Data/MapDocument.swift b/Map/Data/MapDocument.swift index 813b81d..df77abf 100644 --- a/Map/Data/MapDocument.swift +++ b/Map/Data/MapDocument.swift @@ -30,8 +30,7 @@ struct MapDocument: FileDocument { self.text = pendingContent } else if let templatesData = UserDefaults.standard.data(forKey: "mapTemplates"), let templates = try? JSONDecoder().decode([Template].self, from: templatesData), - let defaultTemplate = templates.first(where: { $0.isDefault }) - { + let defaultTemplate = templates.first(where: { $0.isDefault }) { self.text = defaultTemplate.content } else { self.text = String(localized: "map_template.default.content") diff --git a/Map/MapApp.swift b/Map/MapApp.swift index 5e74049..989349c 100644 --- a/Map/MapApp.swift +++ b/Map/MapApp.swift @@ -45,7 +45,7 @@ struct MapApp: App { Settings { PreferencesWindow() } - .onChange(of: appearanceStyle) { _, newValue in + .onChange(of: appearanceStyle) { _, _ in applyAppearanceStyle() } } diff --git a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift index 83d5009..5983745 100644 --- a/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift +++ b/Map/Presentation/Base Components/EvolutionPicker/EvolutionPicker.swift @@ -20,7 +20,7 @@ struct EvolutionPicker: View { @State var isHovered = false @Binding var selectedEvolution: StageType - + var body: some View { Button( diff --git a/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift b/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift index 72a572a..6d2f6c4 100644 --- a/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift +++ b/Map/Presentation/Base Components/EvolutionPicker/GlassEvolutionPicker.swift @@ -20,7 +20,7 @@ struct GlassEvolutionPicker: View { @State var isShowingMenu = false @Binding var selectedEvolution: StageType - + var body: some View { Button( diff --git a/Map/Presentation/Base Components/MapRender/MapBackground.swift b/Map/Presentation/Base Components/MapRender/MapBackground.swift index 710d549..d1e48d8 100644 --- a/Map/Presentation/Base Components/MapRender/MapBackground.swift +++ b/Map/Presentation/Base Components/MapRender/MapBackground.swift @@ -20,7 +20,7 @@ struct MapBackground: View { let mapSize: CGSize let stages: [Double] - + var body: some View { ZStack(alignment: .topLeading) { PatternView( diff --git a/Map/Presentation/Base Components/MapRender/MapGroup.swift b/Map/Presentation/Base Components/MapRender/MapGroup.swift index ca5e954..ccec52f 100644 --- a/Map/Presentation/Base Components/MapRender/MapGroup.swift +++ b/Map/Presentation/Base Components/MapRender/MapGroup.swift @@ -91,6 +91,6 @@ struct MapGroup: View { Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)), Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square), Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle), - Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark), + Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark) ], color: .red) } diff --git a/Map/Presentation/Base Components/MapRender/MapGroups.swift b/Map/Presentation/Base Components/MapRender/MapGroups.swift index 149ea65..8676f1a 100644 --- a/Map/Presentation/Base Components/MapRender/MapGroups.swift +++ b/Map/Presentation/Base Components/MapRender/MapGroups.swift @@ -40,7 +40,7 @@ struct MapGroups: View { Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)), Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square), Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle), - Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark), + Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark) ] ]) } diff --git a/Map/Presentation/Base Components/MapRender/MapIntertias.swift b/Map/Presentation/Base Components/MapRender/MapIntertias.swift index 91ec6f9..9e013c6 100644 --- a/Map/Presentation/Base Components/MapRender/MapIntertias.swift +++ b/Map/Presentation/Base Components/MapRender/MapIntertias.swift @@ -50,6 +50,6 @@ struct MapIntertias: View { mapSize: CGSize(width: 400.0, height: 400.0), vertexSize: CGSize(width: 25.0, height: 25.0), inertias: [ Inertia(id: 0, position: CGPoint(x: 50.0, y: 50.0)), - Inertia(id: 1, position: CGPoint(x: 10.0, y: 20.0)), + Inertia(id: 1, position: CGPoint(x: 10.0, y: 20.0)) ]) } diff --git a/Map/Presentation/Base Components/MapRender/MapMask.swift b/Map/Presentation/Base Components/MapRender/MapMask.swift index c4ba055..05070bf 100644 --- a/Map/Presentation/Base Components/MapRender/MapMask.swift +++ b/Map/Presentation/Base Components/MapRender/MapMask.swift @@ -65,7 +65,7 @@ struct MapMask: View { Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)), Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square), Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle), - Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark), + Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark) ], labelPositions: [:]) } diff --git a/Map/Presentation/Base Components/MapRender/MapVertices.swift b/Map/Presentation/Base Components/MapRender/MapVertices.swift index a3558fa..0ab7fab 100644 --- a/Map/Presentation/Base Components/MapRender/MapVertices.swift +++ b/Map/Presentation/Base Components/MapRender/MapVertices.swift @@ -23,7 +23,7 @@ struct MapVertices: View { let padding = CGFloat(5.0) @State private var offset = CGSize.zero - @State private var draggingVertex: Vertex? = nil + @State private var draggingVertex: Vertex? var onDragVertex: (Vertex, CGFloat, CGFloat) -> Void = { _, _, _ in } @@ -156,7 +156,7 @@ struct MapVertices: View { Vertex(id: 0, label: "A Circle", position: CGPoint(x: 50.0, y: 50.0)), Vertex(id: 1, label: "A Square", position: CGPoint(x: 10.0, y: 20.0), shape: .square), Vertex(id: 2, label: "A triangle", position: CGPoint(x: 25, y: 32.0), shape: .triangle), - Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark), + Vertex(id: 3, label: "An X", position: CGPoint(x: 70.0, y: 70.0), shape: .xMark) ], labelPositions: [:]) } diff --git a/Map/Presentation/Base Components/MapTextEditor/HoverView.swift b/Map/Presentation/Base Components/MapTextEditor/HoverView.swift index eeccec3..69ebfc0 100644 --- a/Map/Presentation/Base Components/MapTextEditor/HoverView.swift +++ b/Map/Presentation/Base Components/MapTextEditor/HoverView.swift @@ -49,7 +49,7 @@ class HoverView: NSView { box.topAnchor.constraint(equalTo: topAnchor), box.leadingAnchor.constraint(equalTo: leadingAnchor), box.trailingAnchor.constraint(equalTo: trailingAnchor), - box.bottomAnchor.constraint(equalTo: bottomAnchor), + box.bottomAnchor.constraint(equalTo: bottomAnchor) ]) let label = NSTextField(labelWithString: message) @@ -89,7 +89,7 @@ class HoverView: NSView { button.leadingAnchor.constraint(equalTo: label.trailingAnchor, constant: 8), button.trailingAnchor.constraint(equalTo: trailingAnchor, constant: -8), - heightAnchor.constraint(equalToConstant: 32), + heightAnchor.constraint(equalToConstant: 32) ]) } diff --git a/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift b/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift index 99fa684..2850c57 100644 --- a/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift +++ b/Map/Presentation/Base Components/MapTextEditor/MapTextEditor.swift @@ -13,12 +13,11 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see https://map.tranquil.systems. import Cocoa -import SwiftUI -import WmapParser import SwiftTreeSitter import SwiftTreeSitterLayer +import SwiftUI import TreeSitterWmap - +import WmapParser class MapTextEditorController: NSViewController { @@ -63,7 +62,7 @@ class MapTextEditorController: NSViewController { self.highlightRanges = highlightRanges self.selectedRange = selectedRange super.init(nibName: nil, bundle: nil) - + if let wmapConfiguration = try? LanguageConfiguration(tree_sitter_wmap(), name: "wmap") { let languageConfiguration = LanguageLayer.Configuration(languageProvider: { name in switch name { @@ -71,7 +70,8 @@ class MapTextEditorController: NSViewController { default: return nil } }) - self.rootLayer = try? LanguageLayer(languageConfig: wmapConfiguration, configuration: languageConfiguration) + self.rootLayer = try? LanguageLayer( + languageConfig: wmapConfiguration, configuration: languageConfiguration) } } @@ -83,7 +83,7 @@ class MapTextEditorController: NSViewController { override func loadView() { let scrollView = NSTextView.scrollableTextView() let textView = scrollView.documentView as! NSTextView - + scrollView.translatesAutoresizingMaskIntoConstraints = false textView.backgroundColor = .Theme.UI.background @@ -105,14 +105,16 @@ class MapTextEditorController: NSViewController { textView.textContainer?.containerSize = NSSize( width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) // Allow text view to grow horizontally - textView.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) + textView.maxSize = NSSize( + width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) // Enable horizontal scrollbar when soft wrap is disabled scrollView.hasHorizontalScroller = true scrollView.horizontalScrollElasticity = .none } else { textView.textContainer?.widthTracksTextView = true // Reset max size for wrapping - textView.maxSize = NSSize(width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) + textView.maxSize = NSSize( + width: CGFloat.greatestFiniteMagnitude, height: CGFloat.greatestFiniteMagnitude) // Hide horizontal scrollbar when soft wrap is enabled scrollView.hasHorizontalScroller = false scrollView.horizontalScrollElasticity = .automatic @@ -291,7 +293,7 @@ class MapTextEditorController: NSViewController { NSLayoutConstraint.activate([ hoverView.leadingAnchor.constraint(equalTo: textView.leadingAnchor, constant: hoverX), - hoverView.topAnchor.constraint(equalTo: textView.topAnchor, constant: hoverY), + hoverView.topAnchor.constraint(equalTo: textView.topAnchor, constant: hoverY) ]) self.hoverView = hoverView @@ -356,7 +358,8 @@ class MapTextEditorController: NSViewController { } private func applyTreeSitterHighlighting(textStorage: NSTextStorage, range: NSRange) { - guard let highlights = try? rootLayer?.highlights(in: range, provider: text.predicateTextProvider) + guard + let highlights = try? rootLayer?.highlights(in: range, provider: text.predicateTextProvider) else { return } for highlight in highlights { @@ -367,11 +370,12 @@ class MapTextEditorController: NSViewController { // Check for missing components if UserDefaults.standard.bool(forKey: "useSmartEditor"), - let parsedMap, - highlight.name == "variable.component_label" { + let parsedMap, + highlight.name == "variable.component_label" { // Extract the component label text from the range - let componentText = (textStorage.string as NSString).substring(with: highlight.range).trimmingCharacters(in: .whitespacesAndNewlines) + let componentText = (textStorage.string as NSString).substring(with: highlight.range) + .trimmingCharacters(in: .whitespacesAndNewlines) // Check if this component exists in the parsed map let componentExists = parsedMap.components.contains(where: { @@ -408,8 +412,7 @@ extension MapTextEditorController: NSTextViewDelegate { } } - func textView(_ view: NSTextView, shouldChangeTextIn: NSRange, replacementString: String?) -> Bool - { + func textView(_ view: NSTextView, shouldChangeTextIn: NSRange, replacementString: String?) -> Bool { let range = Range(shouldChangeTextIn, in: view.string) let target = view.string[range!] @@ -458,7 +461,7 @@ extension MapTextEditorController: NSTextStorageDelegate { } private func colorizeText(textStorage: NSTextStorage) { - let range = NSMakeRange(0, textStorage.length) + let range = NSRange(location: 0, length: textStorage.length) colorizeTextRange(textStorage: textStorage, range: range) } diff --git a/Map/Presentation/Commands/MapCommands.swift b/Map/Presentation/Commands/MapCommands.swift index b992a42..c485023 100644 --- a/Map/Presentation/Commands/MapCommands.swift +++ b/Map/Presentation/Commands/MapCommands.swift @@ -58,7 +58,7 @@ struct MapCommands: Commands { Button("commands.file.export") { if let selectedEvolution, let document { if let image = document.exportAsImage(withEvolution: selectedEvolution) { - + // Capture image data to avoid sendability issues with NSImage guard let tiffData = image.tiffRepresentation else { return } @@ -155,7 +155,7 @@ struct MapCommands: Commands { savePanel.begin { result in if result == .OK { let bitmapImage = NSBitmapImageRep(data: tiffData) - + Task { @MainActor in guard let url = savePanel.url else { return } let selectedFormat = formats[accessoryController.formatPopup.indexOfSelectedItem] diff --git a/Map/Presentation/Complex Components/MapRender/MapRenderView.swift b/Map/Presentation/Complex Components/MapRender/MapRenderView.swift index ba525ad..e2e5004 100644 --- a/Map/Presentation/Complex Components/MapRender/MapRenderView.swift +++ b/Map/Presentation/Complex Components/MapRender/MapRenderView.swift @@ -64,7 +64,7 @@ struct MapRenderView: View { Line(start: CGPoint(x: 0, y: 0), end: CGPoint(x: 0, y: mapSize.height)), Line( start: CGPoint(x: 0, y: mapSize.height), - end: CGPoint(x: mapSize.width, y: mapSize.height)), + end: CGPoint(x: mapSize.width, y: mapSize.height)) ] for vertex in parsed.vertices { @@ -113,7 +113,8 @@ struct MapRenderView: View { Group { MapStages(mapSize: mapSize, lineWidth: lineWidth, stages: renderableMap.stages) MapEdges( - mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize, edges: renderableMap.edges) + mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize, edges: renderableMap.edges + ) MapOpportunities( mapSize: mapSize, lineWidth: lineWidth, vertexSize: vertexSize, opportunities: renderableMap.opportunities) @@ -131,9 +132,10 @@ struct MapRenderView: View { .drawingGroup() .opacity(0.1) } else { - MapGroups(mapSize: mapSize, vertexSize: vertexSize, groups: renderableMap.groups).drawingGroup( - opaque: true - ).opacity(0.1) + MapGroups(mapSize: mapSize, vertexSize: vertexSize, groups: renderableMap.groups) + .drawingGroup( + opaque: true + ).opacity(0.1) } MapNotes( mapSize: mapSize, lineWidth: lineWidth, notes: renderableMap.notes) diff --git a/Map/Presentation/MapEditor.swift b/Map/Presentation/MapEditor.swift index 892c803..c323882 100644 --- a/Map/Presentation/MapEditor.swift +++ b/Map/Presentation/MapEditor.swift @@ -123,7 +123,7 @@ struct MapEditor: View { } .background(Color.Theme.UI.background) .cornerRadius(5.0) - GeometryReader { geometry in + GeometryReader { _ in ScrollView([.horizontal, .vertical], showsIndicators: false) { MapRenderView( parsedMap: parsedMap, evolution: $selectedEvolution, @@ -142,20 +142,20 @@ struct MapEditor: View { .padding(.bottom, Dimensions.MapEditor.additionalPadding) } .background(Color.Theme.UI.background) - .gesture( - MagnificationGesture() - .onChanged { value in - let delta = value / lastZoom - lastZoom = value - zoom = min(max(zoom * delta, zoomRange.lowerBound), zoomRange.upperBound) - } - .onEnded { _ in - lastZoom = 1.0 - } - ) + .gesture( + MagnificationGesture() + .onChanged { value in + let delta = value / lastZoom + lastZoom = value + zoom = min(max(zoom * delta, zoomRange.lowerBound), zoomRange.upperBound) + } + .onEnded { _ in + lastZoom = 1.0 + } + ) } } - + if #unavailable(macOS 26) { Divider() HStack { @@ -249,8 +249,7 @@ struct MapEditor: View { for (index, line) in lines.enumerated() { if let regex = try? NSRegularExpression(pattern: vertexPattern, options: [.caseInsensitive]), - let match = regex.firstMatch(in: line, range: NSRange(line.startIndex..., in: line)) - { + let match = regex.firstMatch(in: line, range: NSRange(line.startIndex..., in: line)) { let nameRange = Range(match.range(at: 1), in: line)! let name = String(line[nameRange]).trimmingCharacters(in: .whitespaces) diff --git a/Map/Presentation/Preferences/GeneralPreferencesView.swift b/Map/Presentation/Preferences/GeneralPreferencesView.swift index 31e54c2..406bee2 100644 --- a/Map/Presentation/Preferences/GeneralPreferencesView.swift +++ b/Map/Presentation/Preferences/GeneralPreferencesView.swift @@ -174,7 +174,7 @@ struct GeneralPreferencesView: View { private func handleExportResult(_ result: Result<URL, Error>) { switch result { - case .success(_): + case .success: // Export successful if exportShouldReset { // Reset preferences if this was an export-and-reset operation diff --git a/Map/Presentation/PreferencesWindow.swift b/Map/Presentation/PreferencesWindow.swift index 3a50119..0865524 100644 --- a/Map/Presentation/PreferencesWindow.swift +++ b/Map/Presentation/PreferencesWindow.swift @@ -102,7 +102,7 @@ struct PreferencesWindow: View { } } } - + private func clipShape() -> AnyShape { if #available(macOS 26.0, *) { AnyShape(RoundedRectangle(cornerRadius: Dimensions.Preferences.Toolbar.glassRadius)) @@ -112,7 +112,6 @@ struct PreferencesWindow: View { } } - #Preview { PreferencesWindow() } diff --git a/Map/Presentation/Theme/Color+theme.swift b/Map/Presentation/Theme/Color+theme.swift index dcc84cb..541bbb6 100644 --- a/Map/Presentation/Theme/Color+theme.swift +++ b/Map/Presentation/Theme/Color+theme.swift @@ -51,7 +51,7 @@ extension Color { Color.Theme.jasperRed, Color.Theme.lightPorcelainGreen, Color.Theme.naplesYellow, - Color.Theme.hermosaPink, + Color.Theme.hermosaPink ] } } diff --git a/Map/Presentation/Theme/Dimensions.swift b/Map/Presentation/Theme/Dimensions.swift index b7c1faf..40ca73d 100644 --- a/Map/Presentation/Theme/Dimensions.swift +++ b/Map/Presentation/Theme/Dimensions.swift @@ -71,9 +71,9 @@ struct Dimensions { struct EvolutionPicker { static var radius: CGFloat { if #available(macOS 26, *) { - return 12.0 + return 12.0 } else { - return 4.0 + return 4.0 } } static let controlSize = 8.0 @@ -89,7 +89,7 @@ struct Dimensions { } } } - + struct Preferences { struct Window { diff --git a/Map/Presentation/Theme/Font+theme.swift b/Map/Presentation/Theme/Font+theme.swift index bb1d8f6..d560d77 100644 --- a/Map/Presentation/Theme/Font+theme.swift +++ b/Map/Presentation/Theme/Font+theme.swift @@ -43,8 +43,7 @@ extension Font { static var note: Font { if UserDefaults.standard.bool(forKey: "useCustomFont"), let customFontName = UserDefaults.standard.string(forKey: "customFontName"), - !customFontName.isEmpty - { + !customFontName.isEmpty { return Font.custom(customFontName, size: Dimensions.FontSize.Map.note).weight(.regular) } return Font.libertinus(size: Dimensions.FontSize.Map.note).weight(.regular) @@ -53,8 +52,7 @@ extension Font { static var axisLabel: Font { if UserDefaults.standard.bool(forKey: "useCustomFont"), let customFontName = UserDefaults.standard.string(forKey: "customFontName"), - !customFontName.isEmpty - { + !customFontName.isEmpty { return Font.custom(customFontName, size: Dimensions.FontSize.Map.axisLabel).weight( .regular) } @@ -64,8 +62,7 @@ extension Font { static var vertexLabel: Font { if UserDefaults.standard.bool(forKey: "useCustomFont"), let customFontName = UserDefaults.standard.string(forKey: "customFontName"), - !customFontName.isEmpty - { + !customFontName.isEmpty { return Font.custom(customFontName, size: Dimensions.FontSize.Map.vertexLabel).weight( .regular) } diff --git a/Map/Presentation/Theme/NSColor+theme.swift b/Map/Presentation/Theme/NSColor+theme.swift index 21db412..5f349a3 100644 --- a/Map/Presentation/Theme/NSColor+theme.swift +++ b/Map/Presentation/Theme/NSColor+theme.swift @@ -29,7 +29,7 @@ extension NSColor { .withAlphaComponent( 0.3) static let error = (NSColor(named: "Jasper Red") ?? .textColor) - + static func colorForSyntax(_ captureName: String) -> NSColor { switch captureName { case ("variable.component_label"): diff --git a/Map/Presentation/Theme/NSFont+theme.swift b/Map/Presentation/Theme/NSFont+theme.swift index 712cc1d..77927a6 100644 --- a/Map/Presentation/Theme/NSFont+theme.swift +++ b/Map/Presentation/Theme/NSFont+theme.swift @@ -31,8 +31,7 @@ extension NSFont { @MainActor static var regular: NSFont { if UserDefaults.standard.bool(forKey: "useCustomEditorFont"), let customEditorFontName = UserDefaults.standard.string(forKey: "customEditorFontName"), - !customEditorFontName.isEmpty - { + !customEditorFontName.isEmpty { return NSFontManager.shared.font( withFamily: customEditorFontName, traits: NSFontTraitMask(), diff --git a/QuickLook/PreviewViewController.swift b/QuickLook/PreviewViewController.swift index ecacee0..9dbc5f2 100644 --- a/QuickLook/PreviewViewController.swift +++ b/QuickLook/PreviewViewController.swift @@ -1,10 +1,10 @@ import Cocoa import Quartz -import SwiftUI -import WmapParser import SwiftTreeSitter import SwiftTreeSitterLayer +import SwiftUI import TreeSitterWmap +import WmapParser class PreviewViewController: NSViewController, QLPreviewingController { @@ -29,7 +29,7 @@ class PreviewViewController: NSViewController, QLPreviewingController { await MainActor.run { // Clear any existing subviews and force cleanup - view.subviews.forEach { subview in + for subview in view.subviews { if let hostingView = subview as? NSHostingView<AnyView> { hostingView.rootView = AnyView(EmptyView()) } @@ -91,7 +91,7 @@ class PreviewViewController: NSViewController, QLPreviewingController { deinit { // Cleanup when view controller is deallocated - view.subviews.forEach { subview in + for subview in view.subviews { if let hostingView = subview as? NSHostingView<AnyView> { hostingView.rootView = AnyView(EmptyView()) } @@ -197,7 +197,9 @@ struct QuickLookTextEditor: NSViewRepresentable { textStorage.addAttribute(.foregroundColor, value: NSColor.textColor, range: fullRange) // Apply tree-sitter highlighting - guard let highlights = try? rootLayer.highlights(in: fullRange, provider: content.predicateTextProvider) + guard + let highlights = try? rootLayer.highlights( + in: fullRange, provider: content.predicateTextProvider) else { return } for highlight in highlights { |