Skip to content

Commit

Permalink
fix: Handle issue with reopening cached editors
Browse files Browse the repository at this point in the history
  • Loading branch information
tomlin7 committed Mar 19, 2024
1 parent 0117954 commit de12aa7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
13 changes: 6 additions & 7 deletions biscuit/core/components/editors/texteditor/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -602,16 +602,15 @@ def detect_encoding(self, file_path):
try:
with open(file_path, 'rb') as file:
bomstring = file.read(8)
detected = chardet.detect(bomstring)
encoding = detected['encoding'].lower()
if encoding == 'ascii':
return 'utf-8'

return encoding
except Exception as e:
# empty file
return 'utf-8'

detected = chardet.detect(bomstring)
encoding = detected['encoding'].lower()
if encoding == 'ascii':
return 'utf-8'

return encoding

def change_eol(self, eol: str):
if not self.exists:
Expand Down
6 changes: 3 additions & 3 deletions biscuit/core/layout/base/content/editors/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import tkinter as tk
import typing
from tkinter.messagebox import askyesno
from typing import List, Union
from typing import Dict, List, Union

from biscuit.core.components.editors import Editor, Welcome
from biscuit.core.components.editors.editor import BaseEditor
Expand Down Expand Up @@ -37,7 +37,7 @@ def __init__(self, master: ContentPane, *args, **kwargs) -> None:
self.tabs = self.editorsbar.tabs

self.active_editors: List[Editor] = []
self.closed_editors: List[Editor] = {}
self.closed_editors: Dict[Editor] = {}

self.emptytab = Empty(self)
self.emptytab.grid(column=0, row=1, sticky=tk.NSEW)
Expand Down Expand Up @@ -165,7 +165,7 @@ def delete_editor(self, editor: Editor) -> None:
self.active_editors.remove(editor)
self.tabs.delete_tab(editor)
if editor.path in self.closed_editors:
self.closed_editors.remove(editor)
self.closed_editors.pop(editor)

editor.destroy()
self.base.explorer.open_editors.remove_item(editor)
Expand Down

0 comments on commit de12aa7

Please sign in to comment.