1
1
---
2
2
name : getEditorFileStatus
3
3
cbbaseinfo :
4
- description : Retrieves the current status of files in the editor.
4
+ description : Retrieves the current status of files in the editor, including information about visible files, open tabs, and editor state .
5
5
cbparameters :
6
6
parameters : []
7
7
returns :
8
- signatureTypeName : Promise
9
- description : A promise that resolves with the editor file status response.
10
- typeArgs : []
8
+ signatureTypeName : Promise<GetEditorFileStatusResponse>
9
+ description : A promise that resolves with the editor file status response containing information about the current editor state.
11
10
data :
12
11
name : getEditorFileStatus
13
12
category : project
@@ -16,29 +15,195 @@ data:
16
15
<CBBaseInfo />
17
16
<CBParameters />
18
17
19
- ## Response Structure
18
+ ### Response Structure
19
+
20
+ The method returns a Promise that resolves to a ` GetEditorFileStatusResponse ` object with the following properties:
21
+
22
+ - ** ` type ` ** (string): Always "getEditorFileStatusResponse".
23
+ - ** ` editorStatus ` ** (string, optional): A formatted string containing information about visible files and open tabs in the editor.
24
+ - ** ` success ` ** (boolean, optional): Indicates if the operation was successful.
25
+ - ** ` message ` ** (string, optional): Additional information about the response.
26
+ - ** ` error ` ** (string, optional): Error details if the operation failed.
27
+ - ** ` messageId ` ** (string, optional): Unique identifier for the message.
28
+ - ** ` threadId ` ** (string, optional): Thread identifier for the request.
29
+
30
+ ### Examples
20
31
21
32
``` javascript
22
- {
23
- type: ' getEditorFileStatusResponse' ,
24
- success: boolean,
25
- message: string,
26
- editorStatus: string
33
+ // Example 1: Basic editor file status retrieval
34
+ const fileStatus = await codebolt .project .getEditorFileStatus ();
35
+ console .log (" Editor Status:" , fileStatus .editorStatus );
36
+
37
+ // Example 2: Processing editor status information
38
+ const editorInfo = await codebolt .project .getEditorFileStatus ();
39
+ if (editorInfo .success && editorInfo .editorStatus ) {
40
+ console .log (" Editor file status retrieved successfully" );
41
+ console .log (" Status details:" , editorInfo .editorStatus );
42
+
43
+ // Parse the status information
44
+ const statusLines = editorInfo .editorStatus .split (' \n ' );
45
+ statusLines .forEach (line => {
46
+ if (line .trim ()) {
47
+ console .log (" Status line:" , line);
48
+ }
49
+ });
27
50
}
51
+
52
+ // Example 3: Error handling for editor status
53
+ try {
54
+ const statusResult = await codebolt .project .getEditorFileStatus ();
55
+
56
+ if (! statusResult .success ) {
57
+ console .error (" Failed to retrieve editor status:" , statusResult .message );
58
+ return ;
59
+ }
60
+
61
+ if (statusResult .editorStatus ) {
62
+ console .log (" Editor status available" );
63
+ } else {
64
+ console .log (" Editor status not available - using defaults" );
65
+ }
66
+ } catch (error) {
67
+ console .error (" Error getting editor file status:" , error);
68
+ }
69
+
70
+ // Example 4: Analyzing editor status
71
+ const analyzeEditorStatus = async () => {
72
+ const statusResponse = await codebolt .project .getEditorFileStatus ();
73
+
74
+ if (! statusResponse .success ) {
75
+ return {
76
+ hasStatus: false ,
77
+ error: statusResponse .message
78
+ };
79
+ }
80
+
81
+ const status = statusResponse .editorStatus || " " ;
82
+
83
+ const analysis = {
84
+ hasStatus: true ,
85
+ hasVisibleFiles: status .includes (" Codebolt Visible Files" ),
86
+ hasOpenTabs: status .includes (" Codebolt Open Tabs" ),
87
+ isDefault: status .includes (" Currently not available - using default values" ),
88
+ rawStatus: status,
89
+ timestamp: new Date ().toISOString ()
90
+ };
91
+
92
+ return analysis;
93
+ };
94
+
95
+ // Example 5: Editor status monitoring
96
+ const monitorEditorStatus = async () => {
97
+ const statusResult = await codebolt .project .getEditorFileStatus ();
98
+
99
+ const monitor = {
100
+ status: statusResult .success ? ' active' : ' inactive' ,
101
+ editorInfo: statusResult .editorStatus ,
102
+ lastChecked: new Date ().toISOString (),
103
+ message: statusResult .message
104
+ };
105
+
106
+ // Log the monitoring information
107
+ console .log (" Editor Status Monitor:" , monitor);
108
+
109
+ return monitor;
110
+ };
111
+
112
+ // Example 6: Editor status for debugging
113
+ const debugEditorStatus = async () => {
114
+ console .log (" 🔍 Debugging editor file status..." );
115
+
116
+ const statusResponse = await codebolt .project .getEditorFileStatus ();
117
+
118
+ console .log (" Response type:" , statusResponse .type );
119
+ console .log (" Success:" , statusResponse .success );
120
+ console .log (" Message:" , statusResponse .message );
121
+ console .log (" Editor Status Length:" , statusResponse .editorStatus ? .length || 0 );
122
+
123
+ if (statusResponse .editorStatus ) {
124
+ console .log (" Editor Status Preview:" ,
125
+ statusResponse .editorStatus .substring (0 , 100 ) + " ..."
126
+ );
127
+ }
128
+
129
+ return statusResponse;
130
+ };
131
+
132
+ // Example 7: Editor status with fallback
133
+ const getEditorStatusWithFallback = async () => {
134
+ try {
135
+ const statusResult = await codebolt .project .getEditorFileStatus ();
136
+
137
+ if (statusResult .success && statusResult .editorStatus ) {
138
+ return {
139
+ source: ' editor' ,
140
+ status: statusResult .editorStatus ,
141
+ success: true
142
+ };
143
+ }
144
+
145
+ // Fallback to default status
146
+ return {
147
+ source: ' fallback' ,
148
+ status: ' Editor status not available' ,
149
+ success: false ,
150
+ message: statusResult .message
151
+ };
152
+ } catch (error) {
153
+ return {
154
+ source: ' error' ,
155
+ status: ' Error retrieving editor status' ,
156
+ success: false ,
157
+ error: error .message
158
+ };
159
+ }
160
+ };
161
+
162
+ // Example 8: Editor status integration
163
+ const integrateEditorStatus = async () => {
164
+ const [editorStatus , projectPath ] = await Promise .all ([
165
+ codebolt .project .getEditorFileStatus (),
166
+ codebolt .project .getProjectPath ()
167
+ ]);
168
+
169
+ const integration = {
170
+ editor: {
171
+ available: editorStatus .success ,
172
+ status: editorStatus .editorStatus ,
173
+ message: editorStatus .message
174
+ },
175
+ project: {
176
+ path: projectPath .path ,
177
+ name: projectPath .projectName
178
+ },
179
+ combined: {
180
+ hasEditorInfo: !! editorStatus .editorStatus ,
181
+ hasProjectInfo: !! projectPath .path ,
182
+ timestamp: new Date ().toISOString ()
183
+ }
184
+ };
185
+
186
+ return integration;
187
+ };
28
188
` ` `
29
189
30
- ## Example
190
+ ### Common Use Cases
31
191
32
- ``` javascript
33
- const fileStatusResult = await codebolt .project .getEditorFileStatus ();
34
- console .log (fileStatusResult);
35
- // Output: {
36
- // type: 'getEditorFileStatusResponse',
37
- // success: true,
38
- // message: 'Default editor status retrieved',
39
- // editorStatus: '\n\n# Codebolt Visible Files\n(Currently not available - using default values)\n\n# Codebolt Open Tabs\n(Currently not available - using default values)'
40
- // }
41
-
42
- // Access editor information
43
- console .log (' Editor Status:' , fileStatusResult .editorStatus );
44
- ```
192
+ 1. **Editor State Monitoring**: Track which files are currently open and visible
193
+ 2. **Development Workflow**: Understand current editor context for automation
194
+ 3. **Session Management**: Restore or save editor state across sessions
195
+ 4. **IDE Integration**: Synchronize external tools with editor state
196
+ 5. **Debugging**: Diagnose editor-related issues and state problems
197
+ 6. **User Interface**: Display current editor status in dashboards or status bars
198
+ 7. **Productivity Tools**: Build tools that work with currently open files
199
+
200
+ ### Notes
201
+
202
+ - The editor status information may not always be available (shows default values when unavailable)
203
+ - The ` editorStatus` field contains formatted text with file and tab information
204
+ - This method provides insight into the current editor context within the development environment
205
+ - The status format includes sections for "Codebolt Visible Files" and "Codebolt Open Tabs"
206
+ - When editor integration is not available, default placeholder text is returned
207
+ - The method is useful for building editor-aware development tools and workflows
208
+ - Consider caching the status if called frequently, as editor state changes often
209
+ - The response format may evolve as editor integration features are enhanced
0 commit comments