Skip to content

Commit a5fab63

Browse files
Fix indent and agenda sorting
1 parent 3736ea6 commit a5fab63

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

lua/orgmode/agenda/views/agenda.lua

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@ local AgendaFilter = require('orgmode.agenda.filter')
88
local utils = require('orgmode.utils')
99

1010
local function sort_by_date_or_priority_or_category(a, b)
11-
if not a.headline_date:is_same(b.headline_date) then
12-
return a.headline_date:is_before(b.headline_date)
13-
end
1411
if a.headline:get_priority_sort_value() ~= b.headline:get_priority_sort_value() then
1512
return a.headline:get_priority_sort_value() > b.headline:get_priority_sort_value()
1613
end
14+
if not a.headline_date:is_same(b.headline_date, 'day') then
15+
return a.headline_date:is_before(b.headline_date)
16+
end
1717
return a.index < b.index
1818
end
1919

@@ -22,13 +22,10 @@ end
2222
local function sort_agenda_items(agenda_items)
2323
table.sort(agenda_items, function(a, b)
2424
if a.is_same_day and b.is_same_day then
25-
if not a.headline_date.date_only and not b.headline_date.date_only then
26-
return a.headline_date:is_before(b.headline_date)
27-
end
28-
if not a.headline_date.date_only then
25+
if not a.headline_date.date_only and b.headline_date.date_only then
2926
return true
3027
end
31-
if not b.headline_date.date_only then
28+
if not b.headline_date.date_only and a.headline_date.date_only then
3229
return false
3330
end
3431
return sort_by_date_or_priority_or_category(a, b)

lua/orgmode/org/indent.lua

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,17 +129,17 @@ local function indentexpr()
129129
match = match or {}
130130
prev_line_match = prev_line_match or {}
131131

132-
if match.type == 'headline' then
133-
return 0
134-
end
135-
136132
if prev_line_match.type == 'headline' then
137-
if noindent_mode then
133+
if noindent_mode or (match.type == 'headline' and match.stars > 0) then
138134
return 0
139135
end
140136
return prev_line_match.indent
141137
end
142138

139+
if match.type == 'headline' then
140+
return 0
141+
end
142+
143143
if match.type == 'list' and prev_line_match.type == 'list' then
144144
local prev_line_list_item = get_is_list_item(vim.fn.getline(prev_linenr))
145145
local cur_line_list_item = get_is_list_item(vim.fn.getline(vim.v.lnum))

0 commit comments

Comments
 (0)