Krazal / nppopenai

OpenAI (aka. ChatGPT) plugin for Notepad++
GNU General Public License v2.0
47 stars 12 forks source link

Selected Text Truncation Issue #22

Open BernoulliBox opened 4 months ago

BernoulliBox commented 4 months ago

I have encountered a bug while using the latest version of the NppOpenAI plugin.

Issue Description: The problem arises when long blocks of text are selected for submission to OpenAI. The selected text within Notepad++ gets truncated to 2048 characters, leading to the original text in the editor being shortened. This truncation issue appears to occur only when the length of the text block exceeds 2048 characters.

Steps to Reproduce the Issue:

  1. Select a long block of text (longer than 2048 characters) in Notepad++.
  2. Submit the selected text to OpenAI using the plugin.

Expected Result: The entire block of text should be submitted to OpenAI, and the selected block of text should remain intact within the Notepad++ editor.

Actual Result: The selected block of text is truncated to 2048 characters. The response from OpenAI appears below the now truncated block.

Additional Information: The issue is reproducible. Aside from this particular issue, the plugin has been performing as expected and is a great tool.

Thank you for your time and for providing such a useful plugin.

Krazal commented 4 months ago

Thank you for your feedback!

Unfortunately, it seems to be a Notepad++ limitation; I use ::SendMessage(nppData._nppHandle, NPPM_GETCURRENTWORD, 9999, (LPARAM)selectedText) to get the selected text (here), but I found a similar issue: https://community.notepad-plus-plus.org/topic/16845/any-way-to-bypass-currentword_maxlength-when-using-nppm_getcurrentword-to-retrieve-selected-text

I'm thinking about a workaround, but still, in the meantime I've added this issue to the NppOpenAI development project.