Cleanup previous PR

This commit is contained in:
Kovid Goyal 2021-07-16 21:43:56 +05:30
parent a9630890fd
commit ac6224563b
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
4 changed files with 13 additions and 4 deletions

View File

@ -13,6 +13,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
boundary rather than the end of the selection. To restore previous behavior
use ``mouse_map right press ungrabbed mouse_selection move-end``.
- When opening hyperlinks, allow defining open actions for directories
(:pull:`3836`)
- Fix a bug in the implementation of the synchronized updates escape code that
could cause incorrect parsing if either the pending buffer capacity or the
pending timeout were exceeded (:iss:`3779`)

View File

@ -85,7 +85,7 @@ lines. The various available criteria are:
:file:`mime.types` in the kitty configuration directory. Useful if your
system MIME database does not have definitions you need. This file is
in the standard format of one definition per line, like: ``text/plain rst
md``.
md``. Note that the MIME type for directories is ``inode/directory``.
``ext``
A comma separated list of file extensions, for example: ``jpeg, tar.gz``

View File

@ -28,8 +28,12 @@ def is_rc_file(path: str) -> bool:
name = os.path.basename(path)
return '.' not in name and name.endswith('rc')
def is_folder(path: str) -> bool:
return os.path.isdir(path)
with suppress(OSError):
return os.path.isdir(path)
return False
def initialize_mime_database() -> None:
if hasattr(initialize_mime_database, 'inited'):
@ -43,7 +47,9 @@ def initialize_mime_database() -> None:
init((local_defs,))
def guess_type(path: str) -> Optional[str]:
def guess_type(path: str, allow_filesystem_access: bool = False) -> Optional[str]:
if allow_filesystem_access and is_folder(path):
return 'inode/directory'
from mimetypes import guess_type as stdlib_guess_type
initialize_mime_database()
mt = None

View File

@ -76,7 +76,7 @@ def url_matches_criterion(purl: 'ParseResult', url: str, unquoted_path: str, mc:
if mc.type == 'mime':
import fnmatch
mt = guess_type(unquoted_path)
mt = guess_type(unquoted_path, allow_filesystem_access=True)
if not mt:
return False
mt = mt.lower()