@@ -286,13 +286,32 @@ class AppDelegate: NSObject, NSApplicationDelegate {
286286 private func filterContexts( _ inputs: inout [ Input ] ) {
287287 debug ( )
288288
289- // 마지막과 동일한 context만 남김, 단 modifier는 언제나 처리
290- if let last = inputs. last {
291- inputs = inputs. filter {
292- $0. context == last. context
293- || ModifierUsage ( rawValue: $0. usage) != nil
289+ // 마지막과 동일한 context만 남김, 단 modifier와 modifier+space는 언제나 처리
290+ guard let last = inputs. last else { return }
291+ var flags = Array ( repeating: false , count: inputs. count)
292+
293+ for (idx, input) in inputs. enumerated ( ) {
294+ if input. context == last. context {
295+ flags [ idx] = true
296+ } else if let modifier = ModifierUsage ( rawValue: input. usage) {
297+ flags [ idx] = true
298+
299+ if input. type == . keyDown {
300+ for (jdx, input) in inputs [ idx..< inputs. endIndex] . enumerated ( ) {
301+ if SpecialUsage ( rawValue: input. usage) == . space {
302+ flags [ idx + jdx] = true
303+ } else if ModifierUsage ( rawValue: input. usage) == modifier && input. type == . keyUp {
304+ break
305+ }
306+ }
307+ }
294308 }
295309 }
310+
311+ debug ( " inputs: \( inputs) " )
312+ debug ( " flags: \( flags) " )
313+
314+ inputs = inputs. indices. filter { flags [ $0] } . map { inputs [ $0] }
296315 }
297316
298317 /** 전처리: 특정 앱에 대해 입력 정리 */
0 commit comments