Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
59 lines (51 loc) · 1.79 KB

File metadata and controls

59 lines (51 loc) · 1.79 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from prompt_toolkit.application import get_app
from prompt_toolkit.enums import DEFAULT_BUFFER
from prompt_toolkit.filters import Condition, Filter
from mycli.packages.special import iocommands
from mycli.packages.special.main import (
CASE_INSENSITIVE_COMMANDS,
CASE_SENSITIVE_COMMANDS,
)
def cli_is_multiline(mycli) -> Filter:
@Condition
def cond():
if not mycli.multi_line:
return False
else:
doc = get_app().layout.get_buffer_by_name(DEFAULT_BUFFER).document
return not _multiline_exception(doc.text)
return cond
def _multiline_exception(text: str) -> bool:
orig = text
text = text.strip()
first_word = text.split()[0] if text else ''
# Multi-statement favorite query is a special case. Because there will
# be a semicolon separating statements, we can't consider semicolon an
# EOL. Let's consider an empty line an EOL instead.
if first_word.startswith(("\\fs", "/fs")):
return orig.endswith("\n")
return (
# Special Command
first_word.startswith("\\")
or (first_word.startswith('/') and not first_word.startswith('/*'))
or text.endswith((
# Ended with the current delimiter (usually a semi-column)
iocommands.get_current_delimiter(),
# or ended with certain commands
"\\g",
"\\G",
"\\x",
r"\e",
r"\edit",
r"\clip",
))
or
# non-backslashed special commands such as "exit" or "help" don't need semicolon
first_word in CASE_SENSITIVE_COMMANDS
or
# uppercase variants accepted
first_word.lower() in CASE_INSENSITIVE_COMMANDS
or
# just a plain enter without any text
(first_word == "")
)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.