-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Tasks In Folder With Spaces (#1978)
* Fix: Tasks In Folder With Spaces * Escape Quotes, Fix Git Client Cases
1 parent
40d6016
commit f24981a
Showing
9 changed files
with
77 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// String+escapedWhiteSpaces.swift | ||
// CodeEdit | ||
// | ||
// Created by Paul Ebose on 2024/07/05. | ||
// | ||
|
||
import Foundation | ||
|
||
extension String { | ||
/// Escapes the string so it's an always-valid directory | ||
func escapedDirectory() -> String { | ||
"\"\(self.escapedQuotes())\"" | ||
} | ||
|
||
/// Returns a new string, replacing all occurrences of ` ` with `\ ` if they aren't already escaped. | ||
func escapedWhiteSpaces() -> String { | ||
escape(replacing: " ") | ||
} | ||
|
||
/// Returns a new string, replacing all occurrences of `"` with `\"` if they aren't already escaped. | ||
func escapedQuotes() -> String { | ||
escape(replacing: #"""#) | ||
} | ||
|
||
func escape(replacing: Character) -> String { | ||
var string = "" | ||
var lastChar: Character? | ||
|
||
for char in self { | ||
defer { | ||
lastChar = char | ||
} | ||
|
||
guard char == replacing else { | ||
string.append(char) | ||
continue | ||
} | ||
|
||
if let lastChar, lastChar == #"\"# { | ||
string.append(char) | ||
continue | ||
} | ||
|
||
string.append(#"\"#) | ||
string.append(char) | ||
} | ||
|
||
return string | ||
} | ||
} |
14 changes: 0 additions & 14 deletions
14
CodeEdit/Utils/Extensions/String/String+escapedWhiteSpaces.swift
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters