1
1
use editor:: { Editor , ToPoint } ;
2
- use gpui:: { AppContext , Subscription , Task , View , WeakView } ;
2
+ use gpui:: { AppContext , FocusHandle , FocusableView , Subscription , Task , View , WeakView } ;
3
3
use schemars:: JsonSchema ;
4
4
use serde:: { Deserialize , Serialize } ;
5
5
use settings:: { Settings , SettingsSources } ;
@@ -22,6 +22,7 @@ pub(crate) struct SelectionStats {
22
22
pub struct CursorPosition {
23
23
position : Option < Point > ,
24
24
selected_count : SelectionStats ,
25
+ context : Option < FocusHandle > ,
25
26
workspace : WeakView < Workspace > ,
26
27
update_position : Task < ( ) > ,
27
28
_observe_active_editor : Option < Subscription > ,
@@ -31,6 +32,7 @@ impl CursorPosition {
31
32
pub fn new ( workspace : & Workspace ) -> Self {
32
33
Self {
33
34
position : None ,
35
+ context : None ,
34
36
selected_count : Default :: default ( ) ,
35
37
workspace : workspace. weak_handle ( ) ,
36
38
update_position : Task :: ready ( ( ) ) ,
@@ -58,7 +60,8 @@ impl CursorPosition {
58
60
match editor. mode ( ) {
59
61
editor:: EditorMode :: AutoHeight { .. }
60
62
| editor:: EditorMode :: SingleLine { .. } => {
61
- cursor_position. position = None
63
+ cursor_position. position = None ;
64
+ cursor_position. context = None ;
62
65
}
63
66
editor:: EditorMode :: Full => {
64
67
let mut last_selection = None :: < Selection < usize > > ;
@@ -87,6 +90,7 @@ impl CursorPosition {
87
90
}
88
91
cursor_position. position =
89
92
last_selection. map ( |s| s. head ( ) . to_point ( & buffer) ) ;
93
+ cursor_position. context = Some ( editor. focus_handle ( cx) ) ;
90
94
}
91
95
}
92
96
@@ -158,6 +162,8 @@ impl Render for CursorPosition {
158
162
) ;
159
163
self . write_position ( & mut text, cx) ;
160
164
165
+ let context = self . context . clone ( ) ;
166
+
161
167
el. child (
162
168
Button :: new ( "go-to-line-column" , text)
163
169
. label_size ( LabelSize :: Small )
@@ -174,12 +180,18 @@ impl Render for CursorPosition {
174
180
} ) ;
175
181
}
176
182
} ) )
177
- . tooltip ( |cx| {
178
- Tooltip :: for_action (
183
+ . tooltip ( move |cx| match context. as_ref ( ) {
184
+ Some ( context) => Tooltip :: for_action_in (
185
+ "Go to Line/Column" ,
186
+ & editor:: actions:: ToggleGoToLine ,
187
+ context,
188
+ cx,
189
+ ) ,
190
+ None => Tooltip :: for_action (
179
191
"Go to Line/Column" ,
180
192
& editor:: actions:: ToggleGoToLine ,
181
193
cx,
182
- )
194
+ ) ,
183
195
} ) ,
184
196
)
185
197
} )
0 commit comments