Skip to content

Commit

Permalink
fix: unauthorized account failed to sign out
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Cherng <[email protected]>
  • Loading branch information
jfcherng committed May 29, 2024
1 parent c1749f9 commit 8c999ba
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions plugin/commands.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
from __future__ import annotations

import os
from abc import ABC
from collections.abc import Callable
from functools import partial, wraps
from pathlib import Path
from typing import Any, cast

import sublime
from LSP.plugin import Request, Session
from LSP.plugin.core.registry import LspTextCommand, LspWindowCommand
from lsp_utils.helpers import rmtree_ex

from .constants import (
PACKAGE_NAME,
Expand Down Expand Up @@ -310,3 +313,20 @@ def _on_result_sign_out(self, payload: CopilotPayloadSignOut) -> None:
if payload["status"] == "NotSignedIn":
CopilotPlugin.set_account_status(signed_in=False, authorized=False)
message_dialog("Sign out OK. Bye!")
return

# see https://github.com/TerminalFi/LSP-copilot/issues/156
if payload["status"] == "NotAuthorized":
if sublime.platform() == "windows":
session_dir = Path(os.environ.get("LOCALAPPDATA", "")) / "github-copilot"
else:
session_dir = Path.home() / ".config/github-copilot"

if not session_dir.is_dir():
message_dialog(f"Failed to find the session directory: {session_dir}", _error=True)
return

rmtree_ex(str(session_dir), ignore_errors=True)
if not session_dir.is_dir():
message_dialog("Sign out OK. Bye!")
return

0 comments on commit 8c999ba

Please sign in to comment.