Skip to content
This repository was archived by the owner on Apr 2, 2024. It is now read-only.

Commit 216268f

Browse files
committed
Fix indent list that spans multiple lines
Fix #222
1 parent e67b50c commit 216268f

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.7.3
2+
3+
* Fix indent list that spans multiple lines
4+
15
## 2.7.2
26

37
* Fix abort insert image from clipboard (when no image in the clipboard)

lib/commands/edit-line.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,8 @@ class EditLine
145145
head.row != tail.row || head.column != tail.column
146146

147147
_replaceLine: (selection, row, line) ->
148-
selection.cursor.setBufferPosition([row, 0])
149-
selection.selectToEndOfLine()
148+
range = selection.cursor.getCurrentLineBufferRange()
149+
selection.setBufferRange(range)
150150
selection.insertText(line)
151151

152152
_isAtLineBeginning: (line, col) ->

spec/commands/edit-line-spec.coffee

+23
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,29 @@ describe "EditLine", ->
298298
editLine.trigger(event)
299299
expect(editor.getText()).toBe(" 1. list")
300300

301+
it "indent long line if it is an ordered list", ->
302+
editor.setText [
303+
"3. Consider a (ordered or unordered) markdown list. On pressing tab to indent the item, if the item spans over more than one line, then the text of the item alters. See the below gif in https://github.com/zhuochun/md-writer/issues/222"
304+
""
305+
"This behaviour is not observed when the list item does not extend to the next line."
306+
].join("\n")
307+
editor.setCursorBufferPosition([0, 5])
308+
309+
editLine.trigger(event)
310+
expect(editor.getText()).toBe [
311+
" 1. Consider a (ordered or unordered) markdown list. On pressing tab to indent the item, if the item spans over more than one line, then the text of the item alters. See the below gif in https://github.com/zhuochun/md-writer/issues/222"
312+
""
313+
"This behaviour is not observed when the list item does not extend to the next line."
314+
].join("\n")
315+
316+
# indent one more time
317+
editLine.trigger(event)
318+
expect(editor.getText()).toBe [
319+
" 1. Consider a (ordered or unordered) markdown list. On pressing tab to indent the item, if the item spans over more than one line, then the text of the item alters. See the below gif in https://github.com/zhuochun/md-writer/issues/222"
320+
""
321+
"This behaviour is not observed when the list item does not extend to the next line."
322+
].join("\n")
323+
301324
it "insert space if it is text", ->
302325
editor.setText "texttext"
303326
editor.setCursorBufferPosition([0, 4])

0 commit comments

Comments
 (0)