| @@ -34,7 +34,7 @@ extension OrgEditor { |
| 34 | if keys.count > 1 { onKeysPending?(nil, []) } |
34 | if keys.count > 1 { onKeysPending?(nil, []) } |
| 35 | let context = editContext() |
35 | let context = editContext() |
| 36 | if let binding = candidates.first(where: { modalRuns($0, in: context) }) { |
36 | if let binding = candidates.first(where: { modalRuns($0, in: context) }) { |
| 37 | if binding.command == "org.fill-paragraph", vim.mode == .visual || vim.mode == .visualLine { |
37 | if binding.command == "org.fill-paragraph", vim.mode == .visual || vim.mode == .visualLine || vim.mode == .visualBlock { |
| 38 | fillVisual() |
38 | fillVisual() |
| 39 | } else { |
39 | } else { |
| 40 | run(binding.command) |
40 | run(binding.command) |
| @@ -57,15 +57,21 @@ extension OrgEditor { |
| 57 | } |
57 | } |
| 58 | } |
58 | } |
| 59 | |
59 | |
| 60 | /// M-q in visual states: `org-fill-paragraph` on the region, the cursor kept. A change |
60 | /// M-q in visual states: `org-fill-paragraph` on the region, the cursor kept. Evil turns |
| 61 | /// deactivates the region, which leaves visual state. |
61 | /// `transient-mark-mode` off in block state, so there it fills the paragraph at the cursor. |
| |
62 | /// A change deactivates the region, which leaves visual state. |
| 62 | private func fillVisual() { |
63 | private func fillVisual() { |
| 63 | let selected = textView.selectedRange() |
64 | let selected = textView.selectedRanges |
| 64 | let cursor = visualCaret ?? selected.location |
65 | let cursor = visualCaret ?? textView.selectedRange().location |
| 65 | let text = document.text |
66 | let text = document.text |
| 66 | perform(FillParagraph(point: cursor)) |
67 | if vim.mode == .visualBlock { |
| |
68 | textView.setSelectedRange(NSRange(location: cursor, length: 0)) |
| |
69 | perform(FillParagraph()) |
| |
70 | } else { |
| |
71 | perform(FillParagraph(point: cursor)) |
| |
72 | } |
| 67 | if document.text == text { |
73 | if document.text == text { |
| 68 | textView.setSelectedRange(selected) |
74 | textView.selectedRanges = selected |
| 69 | visualCaret = cursor |
75 | visualCaret = cursor |
| 70 | } else { |
76 | } else { |
| 71 | vim.reset() |
77 | vim.reset() |
| @@ -91,7 +97,7 @@ extension OrgEditor { |
| 91 | } |
97 | } |
| 92 | } |
98 | } |
| 93 | let wasInsert = vim.mode == .insert |
99 | let wasInsert = vim.mode == .insert |
| 94 | let visual = vim.mode == .visual || vim.mode == .visualLine |
100 | let visual = vim.mode == .visual || vim.mode == .visualLine || vim.mode == .visualBlock |
| 95 | let caret = visual ? (visualCaret ?? textView.selectedRange().location) : textView.selectedRange().location |
101 | let caret = visual ? (visualCaret ?? textView.selectedRange().location) : textView.selectedRange().location |
| 96 | if jumpToFileMark(key) { continue } |
102 | if jumpToFileMark(key) { continue } |
| 97 | let clipboard = NSPasteboard.general.string(forType: .string) |
103 | let clipboard = NSPasteboard.general.string(forType: .string) |