refactor(paste): Remove dead prepend-mode smart spacing path - #1824
Merged
Conversation
The "prepend" mode of applySmartSpacing was never invoked in production since its introduction (#868): the only call site always uses append mode, because the macOS Accessibility read prepend depends on (getPrecedingChar) costs hundreds of ms — too slow for the paste hot path. Delete applyPrepend, its char sets, getPrecedingChar, and the AX preceding-char script, and collapse applySmartSpacing to the single remaining append behavior. No behavior change. The tests covering the removed code are dropped; textEditMonitorPrecedingChar.test.js is renamed to textEditMonitorSelection.test.js since its remaining tests cover selection reads, activation, and monitoring. The dead path already attracted a spurious external bug report (#1787 / #1788).
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Removes the never-used "prepend" mode of the paste-time smart-spacing helper and everything that existed only to serve it:
applyPrepend,OPENING_CHARS,LEADING_PUNCTUATIONinsrc/helpers/smartSpacing.js; with only append mode left, themodedispatch was dead indirection, soapplySmartSpacing(text)is now a single-purpose functionTextEditMonitor.getPrecedingCharandMACOS_AX_PRECEDING_CHAR_SCRIPTinsrc/helpers/textEditMonitor.js(its only consumer)test/helpers/smartSpacing.test.jsipcHandlers.js) passestextdirectly; its comment still records why spacing is append-only (the AX read costs hundreds of ms — too slow for the paste hot path)Why
Prepend mode has never been invoked in production since the module's introduction (#868): the only call site always used append mode, precisely because the macOS Accessibility preceding-char read is too slow for the paste hot path. Dead code per repo standards — git history preserves it if a fast native read ever makes prepend viable. The path already attracted a spurious external bug report (#1787 / #1788).
Reviewer notes
textEditMonitorPrecedingChar.test.jswas renamed totextEditMonitorSelection.test.js, not deleted: beyond the twogetPrecedingChartests (removed), it holds 12 live tests foractivateTargetPid,getSelectedText, and the -25212 native-failure cache, which are unchangedVerification
src/testvoicePillStructureenvironment failures)