Skip to content

Type-ahead: Add no space before suggestions in languages written without spaces - #1405

Open
ekamran wants to merge 1 commit into
WordPress:developfrom
ekamran:shifteq/type-ahead-no-space-cjk
Open

ekamran wants to merge 1 commit into
WordPress:developfrom
ekamran:shifteq/type-ahead-no-space-cjk

Conversation

@ekamran

@ekamran ekamran commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

What?

Closes #1404

An accepted type-ahead suggestion no longer starts with a space after Japanese, Chinese, Thai and other text written without spaces between words.

Why?

The ability trims each suggestion, and addLeadingSpaceIfNeeded() adds a space back whenever the character before the caret is not whitespace. In languages that do not put spaces between words, every accepted suggestion got a stray space (今日は天気が いいですね。), and it was saved with the post.

How?

  • addLeadingSpaceIfNeeded() skips the space when the last character before the caret and the first character of the suggestion are both from a script written without spaces (Han, Hiragana, Katakana, Thai, Lao, Khmer, Myanmar) or are full-width punctuation such as 。 and ,.
  • Both sides have to match, so Latin text after Japanese, or the reverse, still gets the space as before. Korean, which uses spaces, is unchanged.
  • A new e2e test accepts a Japanese suggestion and checks the paragraph reads 今日は天気がいいですね。. On develop it fails with 今日は天気が いいですね。.

Use of AI Tools

AI assistance: Yes
Tool(s): Claude Code and Codex
Used for: Investigation, code, tests, local testing and PR wording. I reviewed the reasoning, the code and the test results, and I take responsibility for the contribution.

Testing Instructions

  1. Enable Type-ahead Text under Settings > AI, with a connected AI provider.
  2. Add a paragraph with 今日は天気が, leave the caret at the end and press Tab when the suggestion shows.
  3. The suggestion is added with no space before it. Try 我今天去 (Chinese) and วันนี้อากาศ (Thai) too.
  4. In English (The weather is) the suggestion still gets its space.

Screenshots or screencast

Six paragraphs after accepting a suggestion with Tab, then saving. Red marks the added space.

Before After
Before: Japanese, Chinese and Thai paragraphs with a space marked red between the typed text and the accepted suggestion; Korean and English with their normal spaces After: the same paragraphs, Japanese, Chinese and Thai joined with no space; Korean and English with their normal spaces

Changelog Entry

Fixed - Type-ahead no longer adds a space before suggestions in Japanese, Chinese, Thai and other languages written without spaces.

Open WordPress Playground Preview

@ekamran
ekamran requested a review from a team November 18, 2026 18:48
@github-actions

Copy link
Copy Markdown

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: ekamran <ekamran@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub or WordPress.org user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.58%. Comparing base (520d656) to head (a74ca94).

Additional details and impacted files
@@            Coverage Diff             @@
##             develop    #1405   +/-   ##
==========================================
  Coverage      85.58%   85.58%           
  Complexity      5087     5087           
==========================================
  Files            193      193           
  Lines          18409    18409           
==========================================
  Hits           15755    15755           
  Misses          2654     2654           
Flag Coverage Δ
unit 85.58% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkotter dkotter added this to the 1.6.0 milestone Nov 18, 2026
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.

Type-ahead: Accepted suggestions start with a space in Japanese, Chinese and Thai

2 participants