File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -108,18 +108,25 @@ def getColor(colorName):
108108 return colorValues [colorName ]
109109
110110def documentIndentMore (document , cursor , globalSettings = globalSettings ):
111+ if globalSettings .tabInsertsSpaces :
112+ indent = ' ' * globalSettings .tabWidth
113+ else :
114+ indent = '\t '
111115 if cursor .hasSelection ():
112116 block = document .findBlock (cursor .selectionStart ())
113117 end = document .findBlock (cursor .selectionEnd ()).next ()
114118 cursor .beginEditBlock ()
115119 while block != end :
116120 cursor .setPosition (block .position ())
117- if globalSettings .tabInsertsSpaces :
118- cursor .insertText (' ' * globalSettings .tabWidth )
119- else :
120- cursor .insertText ('\t ' )
121+ cursor .insertText (indent )
121122 block = block .next ()
122123 cursor .endEditBlock ()
124+ return
125+ block = document .findBlock (cursor .position ())
126+ unorderedListPattern = re .compile (r"^\s*[*-] $" )
127+ if unorderedListPattern .match (block .text ()):
128+ cursor .setPosition (block .position ())
129+ cursor .insertText (indent )
123130 else :
124131 indent = globalSettings .tabWidth - (cursor .positionInBlock ()
125132 % globalSettings .tabWidth )
Original file line number Diff line number Diff line change @@ -69,6 +69,18 @@ def test_indentMoreWithSelection(self):
6969 self .assertEqual (' foo\n bar\n baz' ,
7070 self .document .toPlainText ())
7171
72+ def test_indentMoreInList (self ):
73+ self .document .setPlainText ('- one\n - ' )
74+ cursor = QTextCursor (self .document )
75+ cursor .setPosition (8 )
76+ documentIndentMore (self .document , cursor , self .settings )
77+ self .assertEqual ('- one\n - ' , self .document .toPlainText ())
78+
79+ self .document .setPlainText ('- one\n - ' )
80+ cursor .setPosition (5 )
81+ documentIndentMore (self .document , cursor , self .settings )
82+ self .assertEqual ('- one \n - ' , self .document .toPlainText ())
83+
7284 def test_indentLess (self ):
7385 self .document .setPlainText (' foo' )
7486 cursor = QTextCursor (self .document )
You can’t perform that action at this time.
0 commit comments