OfficeDev / office-js

A repo and NPM package for Office.js, corresponding to a copy of what gets published to the official "evergreen" Office.js CDN, at https://appsforoffice.microsoft.com/lib/1/hosted/office.js.
https://learn.microsoft.com/javascript/api/overview
Other
690 stars 95 forks source link

[Word AddIn] search() failed for the specific Japanese text #5134

Open shinji-morimitsu opened 3 days ago

shinji-morimitsu commented 3 days ago

Provide required information needed to triage your issue

Your Environment

Expected behavior

document.body.search() and paragraph.search() succeeds to search text always, if the text exists in document.

Current behavior

document.body.search() and paragraph.search() fails for the specific Japanese text.

Steps to reproduce

  1. Download docx: https://1drv.ms/w/s!AgVLQPPGbzm6it1aY2DhLfl4l-pf2A?e=UQ09Pl
  2. Download typescript code: https://1drv.ms/t/s!AgVLQPPGbzm6it1bGBoY6xkH4_3Gww?e=zqGmWw
  3. Create new Word AddIn
  4. Add Button, and make it run the function at #2.
  5. Open Word document #1
  6. Open the new Word AddIn at #3
  7. Click button at #4

Link to live example(s)

The program search the partial text of the text in Word document. Therefore all searches should succeed. Inspector snapshot is https://1drv.ms/t/s!AgVLQPPGbzm6it1bGBoY6xkH4_3Gww?e=BQaCtu

Provide additional details

  1. Seems like IME input might be related, if I copy&paste same text as plain text, it does not repro.
  2. English alphabet works well.
  3. For Japanese text, this relatively frequently happens.

Context

We are providing the application that AI review the contract. And our addin has the feature that highlights the sentence on Word that has a risk. In order to highlight the specific text on Word, the program uses 'search text' to make Word.Range. So, this issue has really severe impact on our application.

Useful logs

Thank you for taking the time to report an issue. Our triage team will respond to you in less than 72 hours. Normally, response time is <10 hours Monday through Friday. We do not triage on weekends.

RuizhiSunMS commented 3 days ago

Hi @shinji-morimitsu, thx for reporting here. I did a quick test with scriptlab rather than creating a real addin. The output log would be like the below, which looks as expected. Would you please share that :

  1. whether this case happened both in addin and just with scriptlab?
  2. "For Japanese text, this relatively frequently happens.", do you mean it can't repro stably?

Ps, my version is 2411.

Ok: ま

Ok: まで

Ok: までに

Ok: までにい

Ok: までにいず

Ok: までにいずれ

Ok: までにいずれの

Ok: までにいずれの当

Ok: までにいずれの当事

Ok: までにいずれの当事者

Ok: までにいずれの当事者か

Ok: で

Ok: でに

Ok: でにい

Ok: でにいず

Ok: でにいずれ

Ok: でにいずれの

Ok: でにいずれの当

Ok: でにいずれの当事

Ok: でにいずれの当事者

Ok: でにいずれの当事者か

Ok: に

Ok: にい

Ok: にいず

Ok: にいずれ

Ok: にいずれの

Ok: にいずれの当

Ok: にいずれの当事

Ok: にいずれの当事者

Ok: にいずれの当事者か

Ok: い

Ok: いず

Ok: いずれ

Ok: いずれの

Ok: いずれの当

Ok: いずれの当事

Ok: いずれの当事者

Ok: いずれの当事者か

Ok: ず

Ok: ずれ

Ok: ずれの

Ok: ずれの当

Ok: ずれの当事

Ok: ずれの当事者

Ok: ずれの当事者か

Ok: れ

Ok: れの

Ok: れの当

Ok: れの当事

Ok: れの当事者

Ok: れの当事者か

Ok: の

Ok: の当

Ok: の当事

Ok: の当事者

Ok: の当事者か

Ok: 当

Ok: 当事

Ok: 当事者

Ok: 当事者か

Ok: 事

Ok: 事者

Ok: 事者か

Ok: 者

Ok: 者か

Ok: か
shinji-morimitsu commented 3 days ago

@RuizhiSunMS Hi, Thanks for your reply.

whether this case happened both in addin and just with scriptlab? Yes, both. I ran my script on scriptlab. and result is below.

"For Japanese text, this relatively frequently happens.", do you mean it can't repro stably? For the specific text, it repro stably. However, I cannot find any reason or pattern why the text would cause this problem.

Mine is 2408.

Thanks!

---- my result --- Ok: ま Ok: まで Ok: までに Ok: までにい Ok: までにいず Ok: までにいずれ Failed: までにいずれの Failed: までにいずれの当 Failed: までにいずれの当事 Failed: までにいずれの当事者 Failed: までにいずれの当事者か Ok: で Ok: でに Ok: でにい Ok: でにいず Ok: でにいずれ Ok: でにいずれの Ok: でにいずれの当 Ok: でにいずれの当事 Ok: でにいずれの当事者 Ok: でにいずれの当事者か Ok: に Ok: にい Ok: にいず Ok: にいずれ Ok: にいずれの Ok: にいずれの当 Ok: にいずれの当事 Ok: にいずれの当事者 Ok: にいずれの当事者か Ok: い Ok: いず Ok: いずれ Ok: いずれの Ok: いずれの当 Ok: いずれの当事 Ok: いずれの当事者 Ok: いずれの当事者か Ok: ず Ok: ずれ Ok: ずれの Ok: ずれの当 Ok: ずれの当事 Ok: ずれの当事者 Ok: ずれの当事者か Ok: れ Ok: れの Ok: れの当 Ok: れの当事 Ok: れの当事者 Ok: れの当事者か Ok: の Ok: の当 Ok: の当事 Ok: の当事者 Ok: の当事者か Ok: 当 Ok: 当事 Ok: 当事者 Ok: 当事者か Ok: 事 Ok: 事者 Ok: 事者か Ok: 者 Ok: 者か Ok: か

shinji-morimitsu commented 3 days ago

@RuizhiSunMS I updated Word to 2412 (Build 18318.2000), but this issue still happens.

RuizhiSunMS commented 3 days ago

Hi @shinji-morimitsu, Can we confirm that the repro steps are:

  1. open this doc Download docx: https://1drv.ms/w/s!AgVLQPPGbzm6it1aY2DhLfl4l-pf2A?e=UQ09Pl
  2. add this code Download typescript code: https://1drv.ms/t/s!AgVLQPPGbzm6it1bGBoY6xkH4_3Gww?e=zqGmWw into scriptlab
  3. run code

The steps would lead to reproducing no matter on 2408 or 2411. Please feel free to correct me if I was wrong.

shinji-morimitsu commented 3 days ago

@RuizhiSunMS The issue repro always by my sample script. Please try with Japanese as "Preferred & Proofing enabled" on "Office authoring languages and proofing".

image

RuizhiSunMS commented 2 days ago

@shinji-morimitsu thx, I can repro it. Create #9577164 into our backlog. Our experts would take investigation. Please be patient and we will reply here if any update.