@@ -17,7 +17,7 @@ use super::scene::{
1717 code, column, group, pair, path, pill, rect, runs, squiggle, text, text_width, token, Node ,
1818 CAPTION , STRONG ,
1919} ;
20- use super :: settings:: { ImportFormat , Mode , Scope , Settings } ;
20+ use super :: settings:: { Display , ImportFormat , Mode , Scope , Settings } ;
2121use super :: words:: Words ;
2222use serde_json:: { json, Value } ;
2323
@@ -32,7 +32,7 @@ pub const TOOLS: [&str; 1] = ["python"];
3232/// The settings the cards show; a draft of any of them marks the preview.
3333pub const SETTINGS : [ & str ; 6 ] = [
3434 "typeCheckingMode" ,
35- "disableTypeErrors " ,
35+ "displayTypeErrors " ,
3636 "diagnosticMode" ,
3737 "autoImportCompletions" ,
3838 "importFormat" ,
@@ -139,12 +139,21 @@ struct Card<'a> {
139139 preview : Vec < Node > ,
140140}
141141
142- /// The region's nodes: the interpreter row, then the preview.
142+ /// The region's nodes: the interpreter row, then the preview. While the
143+ /// override path is set, a banner under the row says which commands use it
144+ /// instead.
143145pub fn view ( settings : & Settings , words : & Words , width : Option < f64 > ) -> Vec < Value > {
144- let tools: Vec < Value > = TOOLS
146+ let mut tools: Vec < Value > = TOOLS
145147 . iter ( )
146148 . map ( |tool| json ! ( { "type" : "tool" , "tool" : tool } ) )
147149 . collect ( ) ;
150+ if let Some ( path) = & settings. interpreter_override {
151+ tools. push ( json ! ( {
152+ "type" : "banner" ,
153+ "text" : ( words. override_banner) ( path) ,
154+ "tone" : "accent" ,
155+ } ) ) ;
156+ }
148157 vec ! [
149158 json!( {
150159 "type" : "section" ,
@@ -174,15 +183,20 @@ fn mode_index(mode: Mode) -> usize {
174183/// order the cards stand.
175184fn values < ' a > ( settings : & Settings , words : & ' a Words ) -> [ ( & ' a str , bool , & ' a str ) ; 4 ] {
176185 let switch = |on : bool | if on { words. on } else { words. off } ;
177- let mode = if settings. hide_type_errors {
178- ( words. hidden , false , words. hidden_note )
179- } else {
180- let index = mode_index ( settings. mode ) ;
181- (
182- words. modes [ index] ,
183- settings. mode != Mode :: Off ,
184- words. mode_notes [ index] ,
185- )
186+ let display =
187+ |index : usize , lit : bool | ( words. displays [ index] , lit, words. display_notes [ index] ) ;
188+ let mode = match settings. display {
189+ Display :: AlwaysOn => {
190+ let index = mode_index ( settings. mode ) ;
191+ (
192+ words. modes [ index] ,
193+ settings. mode != Mode :: Off ,
194+ words. mode_notes [ index] ,
195+ )
196+ }
197+ Display :: ConfiguredOnly => display ( 0 , false ) ,
198+ Display :: MissingImports => display ( 1 , true ) ,
199+ Display :: Off => display ( 2 , false ) ,
186200 } ;
187201 let scope = match settings. scope {
188202 Scope :: OpenFiles => ( words. scope_open , false , words. scope_open_note ) ,
@@ -235,7 +249,10 @@ pub fn canvas(settings: &Settings, words: &Words, width: Option<f64>) -> Value {
235249 value : mode. 0 ,
236250 lit : mode. 1 ,
237251 note : mode. 2 ,
238- changed : settings. any_changed ( & [ "typeCheckingMode" , "disableTypeErrors" ] ) ,
252+ // The preset decides this card only while type errors are always on.
253+ changed : settings. is_changed ( "displayTypeErrors" )
254+ || ( settings. display == Display :: AlwaysOn
255+ && settings. is_changed ( "typeCheckingMode" ) ) ,
239256 preview : type_check_preview ( settings. reporting ( ) , words, box_w) ,
240257 } ,
241258 Card {
@@ -435,7 +452,7 @@ fn reported(mode: Mode) -> (usize, Option<usize>) {
435452
436453/// A function missing an annotation, a call with a string for a float, and a
437454/// misspelled name, in a box `box_w` wide; under it what the preset in force
438- /// reports. Nothing is reported while type errors are hidden or off .
455+ /// reports. Nothing is reported while the preset is off or type errors are .
439456fn type_check_preview ( reporting : Option < Mode > , words : & Words , box_w : f64 ) -> Vec < Node > {
440457 let mut nodes = numbered ( vec ! [
441458 vec![
@@ -708,7 +725,7 @@ mod tests {
708725 let mut pairs: Vec < ( & str , & str ) > = w
709726 . modes
710727 . iter ( )
711- . chain ( [ & w. hidden ] )
728+ . chain ( & w. displays )
712729 . map ( |value| ( w. mode_title , * value) )
713730 . collect ( ) ;
714731 pairs. extend ( [ w. scope_open , w. scope_workspace ] . map ( |value| ( w. scope_title , value) ) ) ;
@@ -734,8 +751,7 @@ mod tests {
734751 fn every_note_fits_the_narrowest_card ( ) {
735752 for language in [ "en" , "zh-Hans" ] {
736753 let w = words:: for_language ( language) ;
737- let notes = w. mode_notes . iter ( ) . copied ( ) . chain ( [
738- w. hidden_note ,
754+ let notes = w. mode_notes . iter ( ) . chain ( & w. display_notes ) . copied ( ) . chain ( [
739755 w. scope_open_note ,
740756 w. scope_workspace_note ,
741757 w. import_absolute_note ,
0 commit comments