Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: don't insert preinserted space when not inline_preedit[draft] #1462

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 5 additions & 21 deletions WeaselTSF/Composition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@ class CStartCompositionEditSession : public CEditSession {
public:
CStartCompositionEditSession(com_ptr<WeaselTSF> pTextService,
com_ptr<ITfContext> pContext,
BOOL fCUASWorkaroundEnabled,
BOOL inlinePreeditEnabled)
: CEditSession(pTextService, pContext),
_inlinePreeditEnabled(inlinePreeditEnabled) {
BOOL fCUASWorkaroundEnabled)
: CEditSession(pTextService, pContext) {
_fCUASWorkaroundEnabled = fCUASWorkaroundEnabled;
}

Expand All @@ -21,7 +19,6 @@ class CStartCompositionEditSession : public CEditSession {

private:
BOOL _fCUASWorkaroundEnabled;
BOOL _inlinePreeditEnabled;
};

STDAPI CStartCompositionEditSession::DoEditSession(TfEditCookie ec) {
Expand All @@ -45,22 +42,9 @@ STDAPI CStartCompositionEditSession::DoEditSession(TfEditCookie ec) {
(pComposition != NULL)) {
_pTextService->_SetComposition(pComposition);

/* WORKAROUND:
* CUAS does not provide a correct GetTextExt() position unless the
* composition is filled with characters. So we insert a zero width space
* here. The workaround is only needed when inline preedit is not enabled.
* See https://github.com/rime/weasel/pull/883#issuecomment-1567625762
*/
if (!_inlinePreeditEnabled) {
pRangeComposition->SetText(ec, TF_ST_CORRECTION, L" ", 1);
}

/* set selection */
TF_SELECTION tfSelection;
if (_inlinePreeditEnabled)
pRangeComposition->Collapse(ec, TF_ANCHOR_END);
else
pRangeComposition->Collapse(ec, TF_ANCHOR_START);
pRangeComposition->Collapse(ec, TF_ANCHOR_END);
tfSelection.range = pRangeComposition;
tfSelection.style.ase = TF_AE_NONE;
tfSelection.style.fInterimChar = FALSE;
Expand All @@ -73,8 +57,8 @@ STDAPI CStartCompositionEditSession::DoEditSession(TfEditCookie ec) {
void WeaselTSF::_StartComposition(com_ptr<ITfContext> pContext,
BOOL fCUASWorkaroundEnabled) {
com_ptr<CStartCompositionEditSession> pStartCompositionEditSession;
pStartCompositionEditSession.Attach(new CStartCompositionEditSession(
this, pContext, fCUASWorkaroundEnabled, _cand->style().inline_preedit));
pStartCompositionEditSession.Attach(
new CStartCompositionEditSession(this, pContext, fCUASWorkaroundEnabled));
_cand->StartUI();
if (pStartCompositionEditSession != nullptr) {
HRESULT hr;
Expand Down
4 changes: 1 addition & 3 deletions output/data/weasel.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
# Weasel settings
# encoding: utf-8

config_version: "0.22"
config_version: "0.23"

app_options:
cmd.exe:
ascii_mode: true
conhost.exe:
ascii_mode: true
firefox.exe:
inline_preedit: true # workaround for #946

show_notifications: true
# how long a period notifications shows
Expand Down