Position IME input according to where the selection is rendered

This commit is contained in:
Antonio Scandurra 2022-07-21 17:35:40 +02:00
parent 3c5d7e001e
commit 97ce3998ec
31 changed files with 563 additions and 27 deletions

View file

@ -11,7 +11,7 @@ use gpui::{
fonts::{FontId, HighlightStyle},
Entity, ModelContext, ModelHandle,
};
use language::{Point, Subscription as BufferSubscription};
use language::{OffsetUtf16, Point, Subscription as BufferSubscription};
use settings::Settings;
use std::{any::TypeId, fmt::Debug, num::NonZeroU32, ops::Range, sync::Arc};
use sum_tree::{Bias, TreeMap};
@ -549,6 +549,12 @@ impl ToDisplayPoint for usize {
}
}
impl ToDisplayPoint for OffsetUtf16 {
fn to_display_point(&self, map: &DisplaySnapshot) -> DisplayPoint {
self.to_offset(&map.buffer_snapshot).to_display_point(map)
}
}
impl ToDisplayPoint for Point {
fn to_display_point(&self, map: &DisplaySnapshot) -> DisplayPoint {
map.point_to_display_point(*self, Bias::Left)