Skip to content

Commit

Permalink
Update CodeEditTextView
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoolwinter committed Mar 1, 2024
1 parent 4ee77e3 commit 420b02b
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/CodeEditApp/CodeEditTextView.git",
"state" : {
"revision" : "6653c21a603babf365a12d4d331fadc8f8b52d99",
"version" : "0.7.2"
"revision" : "86b980464bcb67693e2053283c7a99bdc6f358bc",
"version" : "0.7.3"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let package = Package(
// A fast, efficient, text view for code.
.package(
url: "https://github.com/CodeEditApp/CodeEditTextView.git",
from: "0.7.2"
from: "0.7.3"
),
// tree-sitter languages
.package(
Expand Down
17 changes: 17 additions & 0 deletions Sources/CodeEditSourceEditor/Extensions/TextMutation+isEmpty.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// TextMutation+isEmpty.swift
// CodeEditSourceEditor
//
// Created by Khan Winter on 3/1/24.
//

import TextStory

extension TextMutation {
/// Determines if the mutation is an empty mutation.
///
/// Will return `true` if the mutation is neither a delete operation nor an insert operation.
var isEmpty: Bool {
self.string.isEmpty && self.range.isEmpty
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ extension TextView: TextInterface {
}

/// Applies the mutation to the text view.
///
/// If the mutation is empty it will be ignored.
///
/// - Parameter mutation: The mutation to apply.
public func applyMutation(_ mutation: TextMutation) {
guard !mutation.isEmpty else { return }

layoutManager.beginTransaction()
textStorage.beginEditing()

Expand Down

0 comments on commit 420b02b

Please sign in to comment.