File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -119,15 +119,18 @@ string Composition::GetCommitText() const {
119119 return result;
120120}
121121
122- string Composition::GetScriptText () const {
122+ string Composition::GetScriptText (bool keep_selection ) const {
123123 string result;
124124 size_t start = 0 ;
125125 size_t end = 0 ;
126126 for (const Segment& seg : *this ) {
127127 auto cand = seg.GetSelectedCandidate ();
128128 start = end;
129129 end = cand ? cand->end () : seg.end ;
130- if (cand && !cand->preedit ().empty ())
130+ if (keep_selection && cand && !cand->text ().empty () &&
131+ seg.status >= Segment::kSelected )
132+ result += cand->text ();
133+ else if (cand && !cand->preedit ().empty ())
131134 result += boost::erase_first_copy (cand->preedit (), " \t " );
132135 else
133136 result += input_.substr (start, end - start);
Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ class Composition : public Segmentation {
2828 const string& caret) const ;
2929 string GetPrompt () const ;
3030 string GetCommitText () const ;
31- string GetScriptText () const ;
31+ string GetScriptText (bool keep_selection = true ) const ;
3232 RIME_API string GetDebugText () const ;
3333 // Returns text of the last segment before the given position.
3434 string GetTextBefore (size_t pos) const ;
You can’t perform that action at this time.
0 commit comments