Skip to content

Commit

Permalink
fix(ipc): autocomplete for content containing non-ascii characters
Browse files Browse the repository at this point in the history
  • Loading branch information
Cubxity committed May 9, 2023
1 parent fbbc048 commit aacfd90
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src-tauri/src/ipc/commands/typst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ use crate::ipc::model::TypstRenderResponse;
use crate::ipc::{TypstCompileEvent, TypstDocument, TypstSourceError};
use crate::project::ProjectManager;
use base64::Engine;
use log::debug;
use log::{debug, trace};
use serde::Serialize;
use serde_repr::Serialize_repr;
use siphasher::sip128::{Hasher128, SipHasher};
use std::hash::Hash;
use std::panic::catch_unwind;
use std::path::PathBuf;
use std::sync::Arc;
use std::time::Instant;
Expand Down Expand Up @@ -201,6 +200,12 @@ pub async fn typst_autocomplete<R: Runtime>(
let (project, path) = project_path(&window, &project_manager, path)?;
let mut world = project.world.lock().unwrap();

let offset = content
.char_indices()
.nth(offset)
.map(|a| a.0)
.unwrap_or(content.len());

// TODO: Improve error typing
let source_id = world
.slot_update(&*path, Some(content))
Expand Down

0 comments on commit aacfd90

Please sign in to comment.