-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a function to print cell metadata
* This is useful for troubleshooting issues with cell metadata not being set.
- Loading branch information
Showing
4 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as vscode from 'vscode'; | ||
import {FoyleClient, getTraceID} from './client'; | ||
import * as converters from './converters'; | ||
import * as docpb from "../gen/foyle/v1alpha1/doc_pb"; | ||
import * as agentpb from "../gen/foyle/v1alpha1/agent_pb"; | ||
// printCell is a debug tool that prints the contents of a cell to the console | ||
// Its purpose is to help us debug problems by printing the contents of a cell | ||
// In particular the cell metadata | ||
export async function printCell() { | ||
const editor = vscode.window.activeNotebookEditor; | ||
|
||
if (!editor) { | ||
return; | ||
} | ||
|
||
if (editor?.selection.isEmpty) { | ||
return; | ||
} | ||
|
||
// We subtract 1 because end is non-inclusive | ||
const lastSelectedCell = editor?.selection.end - 1; | ||
var lastActiveCell = editor?.notebook.cellAt(lastSelectedCell); | ||
console.log(`Cell value: ${lastActiveCell.document.getText()}`); | ||
console.log(`Cell language: ${lastActiveCell.document.languageId}`); | ||
console.log(`Cell kind: ${lastActiveCell.kind}`); | ||
|
||
Object.keys(lastActiveCell.metadata).forEach(key => { | ||
console.log(`Cell Metadata key: ${key} value: ${lastActiveCell.metadata[key]}`); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters