Skip to content

fix: enable composer autocorrect except on / @ # tokens - #1690

Open
Chessing234 wants to merge 1 commit into
permissionlesstech:mainfrom
Chessing234:fix/composer-token-autocorrect
Open

fix: enable composer autocorrect except on / @ # tokens#1690
Chessing234 wants to merge 1 commit into
permissionlesstech:mainfrom
Chessing234:fix/composer-token-autocorrect

Conversation

@Chessing234

Copy link
Copy Markdown
Contributor

Summary

  • The composer kept .autocorrectionDisabled(true) for every keystroke so /commands, @mentions, and #geohash tokens would not be rewritten. Prose was paying that cost (Enable auto correction when typing a message #969).
  • Disable autocorrect only while the token under the cursor starts with /, @, or #.

Test plan

  • swiftc typecheck of ComposerAutocorrectPolicy.swift under Swift 5 and 6
  • local harness (prose, /, @, #, completed /msg argument, token at cursor)
  • xcodebuild test suite — this machine has Command Line Tools only, no Xcode; CI covers ComposerAutocorrectPolicyTests and the composer wiring
  • type in the composer on a device: a sentence should autocorrect; /msg, @al, and #u4pr should not

Made with Cursor

The composer kept autocorrect off for every keystroke so commands,
mentions, and geohashes would not be rewritten. Prose was paying
that cost. Disable it only while the token under the cursor starts
with /, @, or # (permissionlesstech#969).

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe48c819b7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +80 to +83
ComposerAutocorrectPolicy.shouldDisable(
for: messageText,
cursor: messageText.count
)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Use the text field's real cursor location

When a user moves the caret back into a token that is not at the end of the message—for example, editing Please notify @al tomorrow at @al—this always supplies the end-of-message position. The policy therefore examines tomorrow, enables autocorrection, and can rewrite the mention or geohash that this change is meant to preserve. Track the text field selection/insertion point (or apply a conservative fallback) instead of using messageText.count.

Useful? React with 👍 / 👎.

Comment on lines +19 to +20
if let lastWhitespace = before.lastIndex(where: { $0.isWhitespace }) {
return String(before[before.index(after: lastWhitespace)...])

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Recognize punctuation-adjacent mention and geohash tokens

When a valid token follows punctuation instead of whitespace, such as hello,@al or (#u4pr, this returns the entire whitespace-delimited run and its first character is not @ or #, so autocorrection is enabled. The existing mention and hashtag regexes recognize these substrings without requiring preceding whitespace, meaning this newly enables corrections for supported autocomplete/formatting tokens; locate the marker within the run or use the same token-boundary rules as those parsers.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant