Skip to content

Commit

Permalink
fix(selection): always update last selection text
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed Jun 1, 2018
1 parent 8552734 commit c6aca15
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/selection/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ import { fromEvent } from 'rxjs/observable/fromEvent'
import { timer } from 'rxjs/observable/timer'
import { merge } from 'rxjs/observable/merge'
import { of } from 'rxjs/observable/of'
import { async as asyncScheduler } from 'rxjs/scheduler/async'
import { map } from 'rxjs/operators/map'
import { delay } from 'rxjs/operators/delay'
import { mapTo } from 'rxjs/operators/mapTo'
import { scan } from 'rxjs/operators/scan'
import { filter } from 'rxjs/operators/filter'
import { take } from 'rxjs/operators/take'
import { switchMap } from 'rxjs/operators/switchMap'
import { buffer } from 'rxjs/operators/buffer'
import { debounceTime } from 'rxjs/operators/debounceTime'
import { observeOn } from 'rxjs/operators/observeOn'
import { share } from 'rxjs/operators/share'
import { distinctUntilChanged } from 'rxjs/operators/distinctUntilChanged'

Expand Down Expand Up @@ -94,7 +93,7 @@ const validMouseup$$ = merge(
// if user click on a selected text,
// getSelection would reture the text before the highlight disappears
// delay to wait for selection get cleared
observeOn(asyncScheduler),
delay(10),
share(),
)

Expand Down Expand Up @@ -144,7 +143,6 @@ validMouseup$$.subscribe(({ clientX, clientY }) => {
// Ignore it so that the panel won't follow.
return
}
lastText = text
lastContext = context

sendMessage(
Expand All @@ -163,8 +161,11 @@ validMouseup$$.subscribe(({ clientX, clientY }) => {
},
)
} else {
lastContext = ''
sendEmptyMessage()
}
// always update text
lastText = text
})

function sendMessage (
Expand Down

0 comments on commit c6aca15

Please sign in to comment.