@@ -87,46 +87,21 @@ impl Render for QuickActionBar {
87
87
return div ( ) . id ( "empty quick action bar" ) ;
88
88
} ;
89
89
90
- let (
91
- selection_menu_enabled,
92
- inlay_hints_enabled,
93
- supports_inlay_hints,
94
- inline_diagnostics_enabled,
95
- supports_inline_diagnostics,
96
- git_blame_inline_enabled,
97
- show_git_blame_gutter,
98
- auto_signature_help_enabled,
99
- show_inline_completions,
100
- inline_completion_enabled,
101
- ) = {
102
- let supports_inlay_hints =
103
- editor. update ( cx, |editor, cx| editor. supports_inlay_hints ( cx) ) ;
104
- let editor = editor. read ( cx) ;
105
- let selection_menu_enabled = editor. selection_menu_enabled ( cx) ;
106
- let inlay_hints_enabled = editor. inlay_hints_enabled ( ) ;
107
- let show_inline_diagnostics = editor. show_inline_diagnostics ( ) ;
108
- let supports_inline_diagnostics = editor. inline_diagnostics_enabled ( ) ;
109
- let git_blame_inline_enabled = editor. git_blame_inline_enabled ( ) ;
110
- let show_git_blame_gutter = editor. show_git_blame_gutter ( ) ;
111
- let auto_signature_help_enabled = editor. auto_signature_help_enabled ( cx) ;
112
- let show_edit_predictions = editor. edit_predictions_enabled ( ) ;
113
- let inline_completion_enabled = editor. inline_completions_enabled ( cx) ;
114
-
115
- (
116
- selection_menu_enabled,
117
- inlay_hints_enabled,
118
- supports_inlay_hints,
119
- show_inline_diagnostics,
120
- supports_inline_diagnostics,
121
- git_blame_inline_enabled,
122
- show_git_blame_gutter,
123
- auto_signature_help_enabled,
124
- show_edit_predictions,
125
- inline_completion_enabled,
126
- )
127
- } ;
128
-
129
- let focus_handle = editor. read ( cx) . focus_handle ( cx) ;
90
+ let supports_inlay_hints = editor. update ( cx, |editor, cx| editor. supports_inlay_hints ( cx) ) ;
91
+ let editor_value = editor. read ( cx) ;
92
+ let selection_menu_enabled = editor_value. selection_menu_enabled ( cx) ;
93
+ let inlay_hints_enabled = editor_value. inlay_hints_enabled ( ) ;
94
+ let inline_diagnostics_enabled = editor_value. show_inline_diagnostics ( ) ;
95
+ let supports_inline_diagnostics = editor_value. inline_diagnostics_enabled ( ) ;
96
+ let git_blame_inline_enabled = editor_value. git_blame_inline_enabled ( ) ;
97
+ let show_git_blame_gutter = editor_value. show_git_blame_gutter ( ) ;
98
+ let auto_signature_help_enabled = editor_value. auto_signature_help_enabled ( cx) ;
99
+ let has_edit_prediction_provider = editor_value. edit_prediction_provider ( ) . is_some ( ) ;
100
+ let show_edit_predictions = editor_value. edit_predictions_enabled ( ) ;
101
+ let edit_predictions_enabled_at_cursor =
102
+ editor_value. edit_predictions_enabled_at_cursor ( cx) ;
103
+
104
+ let focus_handle = editor_value. focus_handle ( cx) ;
130
105
131
106
let search_button = editor. is_singleton ( cx) . then ( || {
132
107
QuickActionBarButton :: new (
@@ -328,33 +303,35 @@ impl Render for QuickActionBar {
328
303
} ,
329
304
) ;
330
305
331
- let mut inline_completion_entry = ContextMenuEntry :: new ( "Edit Predictions" )
332
- . toggleable ( IconPosition :: Start , inline_completion_enabled && show_inline_completions)
333
- . disabled ( !inline_completion_enabled)
334
- . action ( Some (
335
- editor:: actions:: ToggleEditPrediction . boxed_clone ( ) ,
336
- ) ) . handler ( {
337
- let editor = editor. clone ( ) ;
338
- move |window, cx| {
339
- editor
340
- . update ( cx, |editor, cx| {
341
- editor. toggle_inline_completions (
342
- & editor:: actions:: ToggleEditPrediction ,
343
- window,
344
- cx,
345
- ) ;
346
- } )
347
- . ok ( ) ;
348
- }
349
- } ) ;
350
- if !inline_completion_enabled {
351
- inline_completion_entry = inline_completion_entry. documentation_aside ( |_| {
352
- Label :: new ( "You can't toggle edit predictions for this file as it is within the excluded files list." ) . into_any_element ( )
353
- } ) ;
306
+ if has_edit_prediction_provider {
307
+ let mut inline_completion_entry = ContextMenuEntry :: new ( "Edit Predictions" )
308
+ . toggleable ( IconPosition :: Start , edit_predictions_enabled_at_cursor && show_edit_predictions)
309
+ . disabled ( !edit_predictions_enabled_at_cursor)
310
+ . action ( Some (
311
+ editor:: actions:: ToggleEditPrediction . boxed_clone ( ) ,
312
+ ) ) . handler ( {
313
+ let editor = editor. clone ( ) ;
314
+ move |window, cx| {
315
+ editor
316
+ . update ( cx, |editor, cx| {
317
+ editor. toggle_edit_predictions (
318
+ & editor:: actions:: ToggleEditPrediction ,
319
+ window,
320
+ cx,
321
+ ) ;
322
+ } )
323
+ . ok ( ) ;
324
+ }
325
+ } ) ;
326
+ if !edit_predictions_enabled_at_cursor {
327
+ inline_completion_entry = inline_completion_entry. documentation_aside ( |_| {
328
+ Label :: new ( "You can't toggle edit predictions for this file as it is within the excluded files list." ) . into_any_element ( )
329
+ } ) ;
330
+ }
331
+
332
+ menu = menu. item ( inline_completion_entry) ;
354
333
}
355
334
356
- menu = menu. item ( inline_completion_entry) ;
357
-
358
335
menu = menu. separator ( ) ;
359
336
360
337
menu = menu. toggleable_entry (
0 commit comments