Skip to content

Better logging for commands in general #607

@nopeless

Description

@nopeless

For some reason this command isn't working for me

Paste html as markdown

And I went to read the source code and debug it

However, it's really hard to pin point where the issue is happening

const pasteHtmlAsMarkdown = async () => {
try {
const tdService = new TurndownService(tdSettings);
const clipboard = await readClipboard();
const markdown = tdService.turndown(clipboard);
const editor = vscode.window.activeTextEditor;
if (!editor) {
return;
}
editor.edit((edit) => {
const current = editor.selection;
editor.selections.forEach((selection) => {
if (selection.isEmpty) {
edit.insert(selection.start, markdown);
} else {
edit.replace(current, markdown);
}
});
});

When I issue the command nothing happens. There could be multiple reasons why thats not happening

  • Is vscode bugged and not issuing the comamnd?
  • Is editor a falsy value?
  • Are selections empty?

I'm just going to manually use turndown for now but I hope you add more logging so its easier to troubleshoot

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions