mirror of
https://github.com/TelegramMessenger/Telegram-iOS.git
synced 2026-07-06 03:33:41 +02:00
Various Fixes
This commit is contained in:
parent
69b36c21f6
commit
9c42eebbbd
12 changed files with 56 additions and 21 deletions
|
|
@ -253,3 +253,20 @@ public func foldLineBreaks(_ text: String) -> String {
|
|||
}
|
||||
return result
|
||||
}
|
||||
|
||||
|
||||
public func trimToLineCount(_ text: String, lineCount: Int) -> String {
|
||||
if lineCount < 1 {
|
||||
return ""
|
||||
}
|
||||
|
||||
let lines = text.split { $0.isNewline }
|
||||
var result = ""
|
||||
for line in lines.prefix(lineCount) {
|
||||
if !result.isEmpty {
|
||||
result += "\n"
|
||||
}
|
||||
result += line
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue