@@ -106,7 +106,7 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
106
106
107
107
// MARK: AppleScript Accessors
108
108
109
- /// String of the selection (Unicode text).
109
+ /// The string of the selection (Unicode text).
110
110
@objc var contents : Any ? {
111
111
112
112
get {
@@ -135,7 +135,7 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
135
135
}
136
136
137
137
138
- /// Character range (location and length) of the selection.
138
+ /// The character range (location and length) of the selection.
139
139
@objc var range : [ Int ] ? {
140
140
141
141
get {
@@ -163,7 +163,7 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
163
163
}
164
164
165
165
166
- /// Line range (location and length) of the selection (list type).
166
+ /// The line range (location and length) of the selection (list type).
167
167
@objc var lineRange : [ Int ] ? {
168
168
169
169
get {
@@ -197,7 +197,7 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
197
197
198
198
// MARK: AppleScript Handlers
199
199
200
- /// Shift the selection to right.
200
+ /// Shifts the selection to right.
201
201
@objc func handleShiftRight( _ command: NSScriptCommand ) {
202
202
203
203
self . textView? . shiftRight ( command)
@@ -265,17 +265,19 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
265
265
266
266
guard
267
267
let argument = command. evaluatedArguments ? [ " caseType " ] as? UInt32 ,
268
- let type = OSACaseType ( rawValue: argument) ,
269
- let textView = self . textView
270
- else { return }
268
+ let type = OSACaseType ( rawValue: argument)
269
+ else {
270
+ command. scriptErrorNumber = OSAParameterMismatch
271
+ return
272
+ }
271
273
272
274
switch type {
273
275
case . lowercase:
274
- textView. lowercaseWord ( command)
276
+ self . textView? . lowercaseWord ( command)
275
277
case . uppercase:
276
- textView. uppercaseWord ( command)
278
+ self . textView? . uppercaseWord ( command)
277
279
case . capitalized:
278
- textView. capitalizeWord ( command)
280
+ self . textView? . capitalizeWord ( command)
279
281
}
280
282
}
281
283
@@ -285,15 +287,17 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
285
287
286
288
guard
287
289
let argument = command. evaluatedArguments ? [ " widthType " ] as? UInt32 ,
288
- let type = OSAWidthType ( rawValue: argument) ,
289
- let textView = self . textView
290
- else { return }
290
+ let type = OSAWidthType ( rawValue: argument)
291
+ else {
292
+ command. scriptErrorNumber = OSAParameterMismatch
293
+ return
294
+ }
291
295
292
296
switch type {
293
297
case . half:
294
- textView. exchangeHalfwidthRoman ( command)
298
+ self . textView? . exchangeHalfwidthRoman ( command)
295
299
case . full:
296
- textView. exchangeFullwidthRoman ( command)
300
+ self . textView? . exchangeFullwidthRoman ( command)
297
301
}
298
302
}
299
303
@@ -303,15 +307,17 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
303
307
304
308
guard
305
309
let argument = command. evaluatedArguments ? [ " kanaType " ] as? UInt32 ,
306
- let type = OSAKanaType ( rawValue: argument) ,
307
- let textView = self . textView
308
- else { return }
310
+ let type = OSAKanaType ( rawValue: argument)
311
+ else {
312
+ command. scriptErrorNumber = OSAParameterMismatch
313
+ return
314
+ }
309
315
310
316
switch type {
311
317
case . hiragana:
312
- textView. exchangeHiragana ( command)
318
+ self . textView? . exchangeHiragana ( command)
313
319
case . katakana:
314
- textView. exchangeKatakana ( command)
320
+ self . textView? . exchangeKatakana ( command)
315
321
}
316
322
}
317
323
@@ -342,11 +348,13 @@ private enum OSAUnicodeNormalizationType: FourCharCode {
342
348
343
349
guard
344
350
let argument = command. evaluatedArguments ? [ " unfType " ] as? UInt32 ,
345
- let type = OSAUnicodeNormalizationType ( rawValue: argument) ,
346
- let textView = self . textView
347
- else { return }
351
+ let type = OSAUnicodeNormalizationType ( rawValue: argument)
352
+ else {
353
+ command. scriptErrorNumber = OSAParameterMismatch
354
+ return
355
+ }
348
356
349
- textView. normalizeUnicode ( form: type. form)
357
+ self . textView? . normalizeUnicode ( form: type. form)
350
358
}
351
359
352
360
0 commit comments