MCPcopy Create free account
hub / github.com/NativeScript/SimDeck / openSourceLocation

Function openSourceLocation

packages/vscode-extension/extension.js:208–229  ·  view source on GitHub ↗
(message)

Source from the content-addressed store, hash-verified

206}
207
208async function openSourceLocation(message) {
209 const file = typeof message.file === "string" ? message.file : "";
210 if (!file || !path.isAbsolute(file)) {
211 throw new Error("source location did not include an absolute file path");
212 }
213
214 const line = positiveInteger(message.line);
215 const column = positiveInteger(message.column);
216 const document = await vscode.workspace.openTextDocument(
217 vscode.Uri.file(file),
218 );
219 const position = new vscode.Position(
220 Math.max(0, (line ?? 1) - 1),
221 Math.max(0, (column ?? 1) - 1),
222 );
223
224 await vscode.window.showTextDocument(document, {
225 preview: true,
226 selection: new vscode.Range(position, position),
227 viewColumn: vscode.ViewColumn.Active,
228 });
229}
230
231function positiveInteger(value) {
232 return Number.isInteger(value) && value > 0 ? value : null;

Callers 1

openSimulatorPanelFunction · 0.85

Calls 2

positiveIntegerFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected