Skip to content

Commit

Permalink
Enable syntax highlighting for preview.
Browse files Browse the repository at this point in the history
  • Loading branch information
luleyleo committed Dec 9, 2024
1 parent ca8efec commit c26f0c9
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions gnome/src/ui/preview/plain_preview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ mod imp {
let buffer = self.buffer();
buffer.set_text(&full_text);

// Setup syntax highlighting
let lm = sourceview5::LanguageManager::default();
let language = lm.guess_language(Some(&file), None);
buffer.set_language(language.as_ref());

// Place cursor on result line.
let mut cursor_position = buffer.start_iter();
cursor_position.forward_lines((result.line() - 1) as i32);
Expand Down

0 comments on commit c26f0c9

Please sign in to comment.