@@ -30,7 +30,6 @@ mod terminal;
31use std::collections::HashSet;
31use std::collections::HashSet;
32use std::io;
32use std::io;
34use std::io::Write;
33use std::io::Write;
35use std::path::Path;
34use std::path::Path;
36use std::process;
35use std::process;
@@ -82,7 +81,7 @@ fn run_cache_subcommand(matches: &clap::ArgMatches) -> Result<()> {
82 } else if matches.is_present("clear") {
81 } else if matches.is_present("clear") {
83 clear_assets();
82 clear_assets();
84 } else if matches.is_present("config-dir") {
83 } else if matches.is_present("config-dir") {
85− writeln!(stdout(), "{}", config_dir())?;
84+ writeln!(io::stdout(), "{}", config_dir())?;
@@ -108,14 +107,11 @@ pub fn list_languages(assets: &HighlightingAssets, term_width: usize) -> Result<
108 // Line-wrapping for the possible file extension overflow.
107 // Line-wrapping for the possible file extension overflow.
109 let desired_width = term_width - longest - separator.len();
108 let desired_width = term_width - longest - separator.len();
110+ let stdout = io::stdout();
111+ let mut stdout = stdout.lock();
111 for lang in languages {
113 for lang in languages {
117− width = longest
114+ write!(stdout, "{:width$}{}", lang.name, separator, width = longest)?;
120 // Number of characters on this line so far, wrap before `desired_width`
116 // Number of characters on this line so far, wrap before `desired_width`
121 let mut num_chars = 0;
117 let mut num_chars = 0;
@@ -126,16 +122,16 @@ pub fn list_languages(assets: &HighlightingAssets, term_width: usize) -> Result<
126 let new_chars = word.len() + comma_separator.len();
122 let new_chars = word.len() + comma_separator.len();
127 if num_chars + new_chars >= desired_width {
123 if num_chars + new_chars >= desired_width {
128 num_chars = 0;
124 num_chars = 0;
129− write!(stdout(), "\n{:width$}{}", "", separator, width = longest)?;
125+ write!(stdout, "\n{:width$}{}", "", separator, width = longest)?;
132 num_chars += new_chars;
128 num_chars += new_chars;
133− write!(stdout(), "{}", Green.paint(&word[..]))?;
129+ write!(stdout, "{}", Green.paint(&word[..]))?;
134 if extension.peek().is_some() {
130 if extension.peek().is_some() {
135− write!(stdout(), "{}", comma_separator)?;
131+ write!(stdout, "{}", comma_separator)?;
138− writeln!(stdout())?;
134+ writeln!(stdout)?;
@@ -148,15 +144,19 @@ pub fn list_themes(assets: &HighlightingAssets, cfg: &Config) -> Result<()> {
148 style.insert(OutputComponent::Plain);
144 style.insert(OutputComponent::Plain);
149 config.files = vec![InputFile::ThemePreviewFile];
145 config.files = vec![InputFile::ThemePreviewFile];
150 config.output_components = OutputComponents(style);
146 config.output_components = OutputComponents(style);
148+ let stdout = io::stdout();
149+ let mut stdout = stdout.lock();
151 for (theme, _) in themes.iter() {
151 for (theme, _) in themes.iter() {
152 writeln!(
152 writeln!(
153− stdout(),
153+ stdout,
154 "Theme: {}\n",
154 "Theme: {}\n",
155 Style::new().bold().paint(theme.to_string())
155 Style::new().bold().paint(theme.to_string())
157 config.theme = theme.to_string();
157 config.theme = theme.to_string();
158 let _controller = Controller::new(&config, &assets).run();
158 let _controller = Controller::new(&config, &assets).run();
159− writeln!(stdout())?;
159+ writeln!(stdout)?;