vtcode_core/terminal_setup/terminals/
vscode.rs1use crate::terminal_setup::detector::TerminalType;
6use crate::terminal_setup::features::multiline;
7use anyhow::Result;
8
9pub fn generate_config(
11 features: &[crate::terminal_setup::detector::TerminalFeature],
12) -> Result<String> {
13 let mut instructions = vec![
14 "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━".to_string(),
15 " VS Code Terminal Manual Configuration".to_string(),
16 "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━".to_string(),
17 String::new(),
18 "VS Code requires adding keybindings to keybindings.json".to_string(),
19 "Follow these steps:".to_string(),
20 String::new(),
21 ];
22
23 for (i, feature) in features.iter().enumerate() {
24 match feature {
25 crate::terminal_setup::detector::TerminalFeature::Multiline => {
26 instructions.push(format!("{}. MULTILINE INPUT (Shift+Enter)", i + 1));
27 instructions.push(String::new());
28 let multiline_instructions = multiline::generate_config(TerminalType::VSCode)?;
29 instructions.push(multiline_instructions);
30 instructions.push(String::new());
31 }
32 crate::terminal_setup::detector::TerminalFeature::CopyPaste => {
33 instructions.push(format!("{}. COPY/PASTE INTEGRATION", i + 1));
34 instructions.push(String::new());
35 instructions.push("Copy/paste is built-in to VS Code terminal.".to_string());
36 instructions.push("No additional configuration needed.".to_string());
37 instructions.push(String::new());
38 instructions.push("Default shortcuts:".to_string());
39 instructions.push(" - Copy: Cmd+C (macOS) / Ctrl+C (Windows/Linux)".to_string());
40 instructions.push(" - Paste: Cmd+V (macOS) / Ctrl+V (Windows/Linux)".to_string());
41 instructions.push(String::new());
42 }
43 crate::terminal_setup::detector::TerminalFeature::ShellIntegration => {
44 instructions.push(format!("{}. SHELL INTEGRATION", i + 1));
45 instructions.push(String::new());
46 instructions.push("VS Code has built-in shell integration.".to_string());
47 instructions.push("To enable:".to_string());
48 instructions.push("1. Open Settings (Cmd+, or Ctrl+,)".to_string());
49 instructions.push(
50 "2. Search for 'terminal.integrated.shellIntegration.enabled'".to_string(),
51 );
52 instructions.push("3. Check the box to enable".to_string());
53 instructions.push(String::new());
54 }
55 crate::terminal_setup::detector::TerminalFeature::ThemeSync => {
56 instructions.push(format!("{}. THEME SYNCHRONIZATION", i + 1));
57 instructions.push(String::new());
58 instructions
59 .push("VS Code terminal automatically matches your editor theme.".to_string());
60 instructions.push("To customize:".to_string());
61 instructions.push("1. Open Settings (Cmd+, or Ctrl+,)".to_string());
62 instructions.push("2. Search for 'workbench.colorCustomizations'".to_string());
63 instructions.push("3. Add terminal color overrides in settings.json".to_string());
64 instructions.push(String::new());
65 }
66 crate::terminal_setup::detector::TerminalFeature::Notifications => {
67 instructions.push(format!("{}. SYSTEM NOTIFICATIONS", i + 1));
68 instructions.push(String::new());
69 instructions.push("VS Code terminal supports notifications through:".to_string());
70 instructions
71 .push("1. Settings → Terminal → Integrated → Bell Duration".to_string());
72 instructions.push("2. Enable 'Terminal > Integrated: Enable Bell'".to_string());
73 instructions.push("3. For external notifications, consider using extensions like 'Notification Test'".to_string());
74 instructions.push(
75 "4. Shell integration can trigger notifications via terminal bell '\\a'"
76 .to_string(),
77 );
78 instructions.push(String::new());
79 }
80 }
81 }
82
83 instructions.push("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━".to_string());
84 instructions
85 .push("After configuration, reload VS Code for changes to take effect.".to_string());
86 instructions.push("━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━".to_string());
87
88 Ok(instructions.join("\n"))
89}
90
91#[cfg(test)]
92mod tests {
93 use super::*;
94 use crate::terminal_setup::detector::TerminalFeature;
95
96 #[test]
97 fn test_generate_instructions() {
98 let features = vec![
99 TerminalFeature::Multiline,
100 TerminalFeature::ShellIntegration,
101 ];
102 let instructions = generate_config(&features).unwrap();
103 assert!(instructions.contains("VS Code"));
104 assert!(instructions.contains("keybindings.json") || instructions.contains("Settings"));
105 assert!(instructions.contains("MULTILINE"));
106 }
107}