| 75 | |
| 76 | editor |
| 77 | } |
| 78 | |
| 79 | /// Create a header editor not bound to an HTTP request entity. |
| 80 | pub fn new_standalone( |
| 81 | initial_headers: Vec<Header>, |
| 82 | completion_engine: Option<CompletionEngine>, |
| 83 | cx: &mut Context<Self>, |
| 84 | ) -> Self { |
| 85 | let pending = if initial_headers.is_empty() { |
| 86 | None |
| 87 | } else { |
| 88 | Some( |
| 89 | initial_headers |
| 90 | .into_iter() |
| 91 | .map(|h| (h.key, h.value, h.enabled)) |
| 92 | .collect(), |
| 93 | ) |
| 94 | }; |
| 95 | Self { |
| 96 | request: None, |
| 97 | header_rows: Vec::new(), |
| 98 | pending_initial_headers: pending, |
| 99 | bulk_mode: false, |
| 100 | bulk_editor: None, |
| 101 | focus_handle: cx.focus_handle(), |
| 102 | completion_engine, |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | fn ensure_bulk_editor(&mut self, window: &mut Window, cx: &mut Context<Self>) { |
| 107 | if self.bulk_editor.is_none() { |
| 108 | let completion_engine = self.completion_engine.clone(); |