Cleanup previous PR
This commit is contained in:
parent
a9630890fd
commit
ac6224563b
@ -13,6 +13,9 @@ To update |kitty|, :doc:`follow the instructions <binary>`.
|
|||||||
boundary rather than the end of the selection. To restore previous behavior
|
boundary rather than the end of the selection. To restore previous behavior
|
||||||
use ``mouse_map right press ungrabbed mouse_selection move-end``.
|
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
|
- 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
|
could cause incorrect parsing if either the pending buffer capacity or the
|
||||||
pending timeout were exceeded (:iss:`3779`)
|
pending timeout were exceeded (:iss:`3779`)
|
||||||
|
|||||||
@ -85,7 +85,7 @@ lines. The various available criteria are:
|
|||||||
:file:`mime.types` in the kitty configuration directory. Useful if your
|
:file:`mime.types` in the kitty configuration directory. Useful if your
|
||||||
system MIME database does not have definitions you need. This file is
|
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
|
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``
|
``ext``
|
||||||
A comma separated list of file extensions, for example: ``jpeg, tar.gz``
|
A comma separated list of file extensions, for example: ``jpeg, tar.gz``
|
||||||
|
|||||||
@ -28,8 +28,12 @@ def is_rc_file(path: str) -> bool:
|
|||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
return '.' not in name and name.endswith('rc')
|
return '.' not in name and name.endswith('rc')
|
||||||
|
|
||||||
|
|
||||||
def is_folder(path: str) -> bool:
|
def is_folder(path: str) -> bool:
|
||||||
|
with suppress(OSError):
|
||||||
return os.path.isdir(path)
|
return os.path.isdir(path)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def initialize_mime_database() -> None:
|
def initialize_mime_database() -> None:
|
||||||
if hasattr(initialize_mime_database, 'inited'):
|
if hasattr(initialize_mime_database, 'inited'):
|
||||||
@ -43,7 +47,9 @@ def initialize_mime_database() -> None:
|
|||||||
init((local_defs,))
|
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
|
from mimetypes import guess_type as stdlib_guess_type
|
||||||
initialize_mime_database()
|
initialize_mime_database()
|
||||||
mt = None
|
mt = None
|
||||||
|
|||||||
@ -76,7 +76,7 @@ def url_matches_criterion(purl: 'ParseResult', url: str, unquoted_path: str, mc:
|
|||||||
|
|
||||||
if mc.type == 'mime':
|
if mc.type == 'mime':
|
||||||
import fnmatch
|
import fnmatch
|
||||||
mt = guess_type(unquoted_path)
|
mt = guess_type(unquoted_path, allow_filesystem_access=True)
|
||||||
if not mt:
|
if not mt:
|
||||||
return False
|
return False
|
||||||
mt = mt.lower()
|
mt = mt.lower()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user