Skip to content

Commit e5027bd

Browse files
feat(Sky): Include active view column in editor state push to Mountain
The `sky:editor:activeChanged` and `sky:editor:selectionChanged` IPC payloads were hardcoded to `viewColumn: 1`, causing extensions querying `window.activeTextEditor.viewColumn` to always receive column 1 regardless of the actual editor group position. Add a `GetViewColumn()` helper that reads `EditorGroups.activeGroup.index` (0-based) and converts to the 1-based view column expected by the VS Code extension API. The helper safely falls back to 1 when the EditorGroups service isn't yet available. Extensions relying on the active editor's view column now receive the correct value matching the editor's position in the group layout.
1 parent 47d08be commit e5027bd

1 file changed

Lines changed: 28 additions & 2 deletions

File tree

Source/Function/Sky/Bridge/InstallEditorOperations.ts

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,20 @@ export default async (Dependencies: {
124124
try {
125125
const Services = GetServices();
126126
const CodeEditorService = (Services as any)?.CodeEditorService;
127+
128+
// Resolve the view column (1-based) for the active editor group.
129+
// `EditorGroups.activeGroup.index` is 0-based, so we add 1.
130+
// Falls back to 1 when the service isn't yet available.
131+
const GetViewColumn = (): number => {
132+
try {
133+
const Groups = (Services as any)?.EditorGroups;
134+
const Idx = Groups?.activeGroup?.index;
135+
return typeof Idx === "number" ? Idx + 1 : 1;
136+
} catch {
137+
return 1;
138+
}
139+
};
140+
127141
if (CodeEditorService?.onDidChangeActiveCodeEditor) {
128142
CodeEditorService.onDidChangeActiveCodeEditor((Ed: any) => {
129143
try {
@@ -132,7 +146,13 @@ export default async (Dependencies: {
132146
const Sels = Ed?.getSelections?.() ?? [];
133147
Invoke("MountainIPCInvoke", {
134148
method: "sky:editor:activeChanged",
135-
params: [{ uri: Uri, selections: Sels, viewColumn: 1 }],
149+
params: [
150+
{
151+
uri: Uri,
152+
selections: Sels,
153+
viewColumn: GetViewColumn(),
154+
},
155+
],
136156
}).catch(() => {});
137157
} catch {}
138158
});
@@ -150,7 +170,13 @@ export default async (Dependencies: {
150170
: [];
151171
Invoke("MountainIPCInvoke", {
152172
method: "sky:editor:selectionChanged",
153-
params: [{ uri: Uri, selections: Sels }],
173+
params: [
174+
{
175+
uri: Uri,
176+
selections: Sels,
177+
viewColumn: GetViewColumn(),
178+
},
179+
],
154180
}).catch(() => {});
155181
} catch {}
156182
});

0 commit comments

Comments
 (0)