Skip to content

Commit

Permalink
fixed issue with dropped empty strings between EOLs
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick Kibysh committed Jul 28, 2021
1 parent 36c278f commit d4a9955
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nRF Toolbox/Profiles/UART/Model/UARTCommandModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct TextCommand: UARTCommandModel, Equatable {
])
}

var title: String { text }
var title: String { text.split(whereSeparator: \.isNewline).joined() }

var data: Data {
text.data(using: .utf8)!
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ class UARTNewCommandViewController: UIViewController {
let image = CommandImage.allCases[selectedItem]

if typeSegmentControl.selectedSegmentIndex == 0 {
let text = textView.text.split(separator: "\n").joined(separator: self.eolSymbol())
let slices = textView.text.split(omittingEmptySubsequences: false, whereSeparator: \.isNewline)
let text = slices.joined(separator: eolSymbol())

command = TextCommand(text: text, image: image, eol: self.eolSymbol())
} else {
command = DataCommand(data: Data(valueTextField.text!.hexa), image: image)
Expand Down

0 comments on commit d4a9955

Please sign in to comment.