parent
fe2ab12c39
commit
980891c3df
2
pylintrc
2
pylintrc
@ -54,7 +54,7 @@ disable=
|
||||
output-format=text
|
||||
|
||||
# Tells whether to display a full report or only the messages
|
||||
reports=yes
|
||||
reports=no
|
||||
|
||||
msg-template="{path}:{line}: [{msg_id}({symbol}), {obj}] {msg}"
|
||||
|
||||
|
@ -6,6 +6,7 @@ selected and insert it here. If there was no text visually selected, this will
|
||||
be the empty string. """
|
||||
|
||||
import re
|
||||
import textwrap
|
||||
|
||||
import UltiSnips._vim as _vim
|
||||
from UltiSnips.indent_util import IndentUtil
|
||||
@ -34,21 +35,21 @@ class Visual(NoneditableTextObject, TextObjectTransformation):
|
||||
TextObjectTransformation.__init__(self, token)
|
||||
|
||||
def _update(self, done):
|
||||
if self._mode != "v":
|
||||
# Keep the indent for Line/Block Selection
|
||||
if self._mode == "v": # Normal selection.
|
||||
text = self._text
|
||||
else: # Block selection or line selection.
|
||||
text_before = _vim.buf[self.start.line][:self.start.col]
|
||||
indent = _REPLACE_NON_WS.sub(" ", text_before)
|
||||
iu = IndentUtil()
|
||||
indent = iu.indent_to_spaces(indent)
|
||||
indent = iu.spaces_to_indent(indent)
|
||||
text = ""
|
||||
for idx, line in enumerate(self._text.splitlines(True)):
|
||||
for idx, line in enumerate(textwrap.dedent(
|
||||
self._text).splitlines(True)):
|
||||
if idx != 0:
|
||||
text += indent
|
||||
text += line
|
||||
text = text[:-1] # Strip final '\n'
|
||||
else:
|
||||
text = self._text
|
||||
|
||||
text = self._transform(text)
|
||||
self.overwrite(text)
|
||||
|
4
test.py
4
test.py
@ -1734,6 +1734,10 @@ class Visual_LineSelect_CheckIndentWithTS_NoOverwrite(_VimTest):
|
||||
snippets = ("test", "beg\n\t${0:${VISUAL}}\nend")
|
||||
keys = "hello\nnice\nworld" + ESC + "Vkk" + EX + "test" + EX
|
||||
wanted = "beg\n\thello\n\tnice\n\tworld\nend"
|
||||
class Visual_LineSelect_DedentLine(_VimTest):
|
||||
snippets = ("if", "if {\n\t${VISUAL}$0\n}")
|
||||
keys = "if" + EX + "one\n\ttwo\n\tthree" + ESC + ARR_U*2 + "V" + ARR_D + EX + "\tif" + EX
|
||||
wanted = "if {\n\tif {\n\t\tone\n\t\ttwo\n\t}\n\tthree\n}"
|
||||
|
||||
class VisualTransformation_SelectOneWord(_VimTest):
|
||||
snippets = ("test", r"h${VISUAL/./\U$0\E/g}b")
|
||||
|
Loading…
Reference in New Issue
Block a user