diff --git a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift index b7abfa1ff1..af4ee347e7 100644 --- a/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift +++ b/CodeEdit/Features/StatusBar/Views/StatusBarItems/StatusBarCursorLocationLabel.swift @@ -11,6 +11,8 @@ import CodeEditSourceEditor struct StatusBarCursorLocationLabel: View { @Environment(\.controlActiveState) private var controlActive + @Environment(\.modifierKeys) + private var modifierKeys @EnvironmentObject private var model: UtilityAreaViewModel @EnvironmentObject private var editorManager: EditorManager @@ -38,11 +40,18 @@ struct StatusBarCursorLocationLabel: View { return "" } + // More than one selection, display the number of selections. if cursorPositions.count > 1 { return "\(cursorPositions.count) selected ranges" } + // If the selection is more than just a cursor, return the length. if cursorPositions[0].range.length > 0 { + // When the option key is pressed display the character range. + if modifierKeys.contains(.option) { + return "Char: \(cursorPositions[0].range.location) Len: \(cursorPositions[0].range.length)" + } + let lineCount = getLines(cursorPositions[0].range) if lineCount > 1 { @@ -52,6 +61,12 @@ struct StatusBarCursorLocationLabel: View { return "\(cursorPositions[0].range.length) characters" } + // When the option key is pressed display the character offset. + if modifierKeys.contains(.option) { + return "Char: \(cursorPositions[0].range.location) Len: 0" + } + + // When there's a single cursor, display the line and column. return "Line: \(cursorPositions[0].line) Col: \(cursorPositions[0].column)" }