aboutsummaryrefslogtreecommitdiff
path: root/helix-view/src/document.rs
diff options
context:
space:
mode:
Diffstat (limited to 'helix-view/src/document.rs')
-rw-r--r--helix-view/src/document.rs20
1 files changed, 12 insertions, 8 deletions
diff --git a/helix-view/src/document.rs b/helix-view/src/document.rs
index 33137c6c..4e7b1de9 100644
--- a/helix-view/src/document.rs
+++ b/helix-view/src/document.rs
@@ -681,7 +681,7 @@ impl Document {
pub fn open(
path: &Path,
encoding: Option<&'static Encoding>,
- config_loader: Option<Arc<syntax::Loader>>,
+ config_loader: Option<Arc<ArcSwap<syntax::Loader>>>,
config: Arc<dyn DynAccess<Config>>,
) -> Result<Self, Error> {
// Open the file if it exists, otherwise assume it is a new file (and thus empty).
@@ -922,10 +922,11 @@ impl Document {
}
/// Detect the programming language based on the file type.
- pub fn detect_language(&mut self, config_loader: Arc<syntax::Loader>) {
+ pub fn detect_language(&mut self, config_loader: Arc<ArcSwap<syntax::Loader>>) {
+ let loader = config_loader.load();
self.set_language(
- self.detect_language_config(&config_loader),
- Some(config_loader),
+ self.detect_language_config(&loader),
+ Some(Arc::clone(&config_loader)),
);
}
@@ -1059,10 +1060,12 @@ impl Document {
pub fn set_language(
&mut self,
language_config: Option<Arc<helix_core::syntax::LanguageConfiguration>>,
- loader: Option<Arc<helix_core::syntax::Loader>>,
+ loader: Option<Arc<ArcSwap<helix_core::syntax::Loader>>>,
) {
if let (Some(language_config), Some(loader)) = (language_config, loader) {
- if let Some(highlight_config) = language_config.highlight_config(&loader.scopes()) {
+ if let Some(highlight_config) =
+ language_config.highlight_config(&(*loader).load().scopes())
+ {
self.syntax = Syntax::new(self.text.slice(..), highlight_config, loader);
}
@@ -1078,9 +1081,10 @@ impl Document {
pub fn set_language_by_language_id(
&mut self,
language_id: &str,
- config_loader: Arc<syntax::Loader>,
+ config_loader: Arc<ArcSwap<syntax::Loader>>,
) -> anyhow::Result<()> {
- let language_config = config_loader
+ let language_config = (*config_loader)
+ .load()
.language_config_for_language_id(language_id)
.ok_or_else(|| anyhow!("invalid language id: {}", language_id))?;
self.set_language(Some(language_config), Some(config_loader));