-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Indent Options and Clarify Tab Width (#171)
<!--- IMPORTANT: If this PR addresses multiple unrelated issues, it will be closed until separated. --> ### Description > This is a near clone of #147, but git got messed up on that branch. This PR improves that branch anyways. This enables configuration of the behavior when the tab key is pressed. Previously all tabs were converted to spaces and inserted `tabWidth` spaces in place of the tab character. This PR clarifies that the `tabWidth` parameter should be used for the *visual* width of tabs, and adds an `indentOption` parameter that specifies how to handle inserting tab characters. Adds an `IndentOption` enum with two cases for this behavior: - `spaces(count: Int)` - `tab` If `spaces(count: Int)` is specified, the editor will insert the given number of spaces when the tab key is pressed, otherwise the tab character will be kept. ### Related Issues <!--- REQUIRED: Tag all related issues (e.g. * #123) --> <!--- If this PR resolves the issue please specify (e.g. * closes #123) --> <!--- If this PR addresses multiple issues, these issues must be related to one other --> * #80 - Does not close, needs an additional PR for the tab width setting. ### Checklist <!--- Add things that are not yet implemented above --> - [x] I read and understood the [contributing guide](https://github.com/CodeEditApp/CodeEdit/blob/main/CONTRIBUTING.md) as well as the [code of conduct](https://github.com/CodeEditApp/CodeEdit/blob/main/CODE_OF_CONDUCT.md) - [x] The issues this PR addresses are related to each other - [x] My changes generate no new warnings - [x] My code builds and runs on my machine - [x] My changes are all related to the related issue above - [x] I documented my code ### Screenshots https://user-images.githubusercontent.com/35942988/228014785-85a20e2e-0465-4767-9d53-b97b4df2e11e.mov
- Loading branch information
1 parent
a60580a
commit 169e4ea
Showing
8 changed files
with
150 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// | ||
// IndentOption.swift | ||
// | ||
// | ||
// Created by Khan Winter on 3/26/23. | ||
// | ||
|
||
/// Represents what to insert on a tab key press. | ||
public enum IndentOption: Equatable { | ||
case spaces(count: Int) | ||
case tab | ||
|
||
var stringValue: String { | ||
switch self { | ||
case .spaces(let count): | ||
return String(repeating: " ", count: count) | ||
case .tab: | ||
return "\t" | ||
} | ||
} | ||
|
||
public static func == (lhs: IndentOption, rhs: IndentOption) -> Bool { | ||
switch (lhs, rhs) { | ||
case (.tab, .tab): | ||
return true | ||
case (.spaces(let lhsCount), .spaces(let rhsCount)): | ||
return lhsCount == rhsCount | ||
default: | ||
return false | ||
} | ||
} | ||
} |
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
Oops, something went wrong.