Skip to content

Commit 80bc7ab

Browse files
authored
Add config option search_max_lines (#614)
See #609.
1 parent cbffe2a commit 80bc7ab

File tree

4 files changed

+7
-1
lines changed

4 files changed

+7
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
### Added
1111

1212
- Added config option `ui.max_file_length` to disable the UI for files with more than this many lines. Defaults to 5000.
13+
- Added config option `search_max_lines` (defaults to 1000) for controlling the max number of lines read from disk from note files during certain searches.
1314

1415
## [v3.7.13](https://github.com/epwalsh/obsidian.nvim/releases/tag/v3.7.13) - 2024-05-31
1516

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,9 @@ This is a complete list of all of the options that can be passed to `require("ob
418418
sort_by = "modified",
419419
sort_reversed = true,
420420

421+
-- Set the maximum number of lines to read from notes on disk when performing certain searches.
422+
search_max_lines = 1000,
423+
421424
-- Optional, determines how certain commands open notes. The valid options are:
422425
-- 1. "current" (the default) - to always open in the current window
423426
-- 2. "vsplit" - to open in a vertical split if there's not already a vertical split

lua/obsidian/client.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@ Client.find_tags_async = function(self, term, callback, opts)
10801080
---@param path obsidian.Path
10811081
---@return { [1]: obsidian.Note, [2]: {[1]: integer, [2]: integer}[] }
10821082
local load_note = function(path)
1083-
local note, contents = Note.from_file_with_contents_async(path)
1083+
local note, contents = Note.from_file_with_contents_async(path, { max_lines = self.opts.search_max_lines or 1000 })
10841084
return { note, search.find_code_blocks(contents) }
10851085
end
10861086

lua/obsidian/config.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ local config = {}
2727
---@field open_app_foreground boolean|?
2828
---@field sort_by obsidian.config.SortBy|?
2929
---@field sort_reversed boolean|?
30+
---@field search_max_lines integer
3031
---@field open_notes_in obsidian.config.OpenStrategy
3132
---@field ui obsidian.config.UIOpts | table<string, any>
3233
---@field attachments obsidian.config.AttachmentsOpts
@@ -59,6 +60,7 @@ config.ClientOpts.default = function()
5960
open_app_foreground = false,
6061
sort_by = "modified",
6162
sort_reversed = true,
63+
search_max_lines = 1000,
6264
open_notes_in = "current",
6365
ui = config.UIOpts.default(),
6466
attachments = config.AttachmentsOpts.default(),

0 commit comments

Comments
 (0)