@@ -207,80 +207,84 @@ local function generate_preview(entry)
207207 end
208208
209209 local file_exists = vim .fn .filereadable (entry .path ) == 1
210-
211210 if not file_exists then
212211 return string.format (' File Not Found\n Path: %s' , entry .path )
213212 end
214213
215214 local separator_width = 120
215+ local context_before = 10
216+ local context_after = 20
217+
216218 local lines = {}
217219 local metadata = get_file_metadata (entry .path )
218220
219- -- Read file content
220221 local file_lines = vim .fn .readfile (entry .path )
221222 local total_lines = # file_lines
222223 local target_line = entry .lnum or 1
223224
224- -- Ensure target line is valid
225225 if target_line > total_lines then
226226 target_line = total_lines
227227 end
228228
229- -- Enhanced context calculation
230- local context_before = 8
231- local context_after = 8
232229 local start_line = math.max (1 , target_line - context_before )
233230 local end_line = math.min (total_lines , target_line + context_after )
234231
235- -- File header with metadata
236232 local file_icon , _ = get_filetype_icon (entry .path )
237233 local rel_path = vim .fn .fnamemodify (entry .path , ' :.' )
238234 local filetype = vim .filetype .match ({ filename = entry .path }) or ' text'
239235
240- table.insert (lines , string.format (' %s %s' , file_icon , rel_path ))
236+ table.insert (lines , string.format (' # %s %s' , file_icon , rel_path ))
241237 table.insert (lines , string.rep (' ─' , separator_width ))
242238
243- -- Mark/Bookmark information
239+ table.insert (
240+ lines ,
241+ string.format (' Size: %s | Modified: %s' , metadata .size or ' Unknown' , metadata .modified or ' Unknown' )
242+ )
244243 if entry .mark then
245244 local mark_icon , mark_desc = get_mark_type_info (entry .mark )
246- table.insert (lines , string.format (' %sMark: %s (%s)' , mark_icon , entry .mark , mark_desc ))
245+ table.insert (
246+ lines ,
247+ string.format (
248+ ' %sMark: Ln %d, Col %d %s (%s)' ,
249+ mark_icon ,
250+ target_line ,
251+ entry .col or 1 ,
252+ entry .mark ,
253+ mark_desc
254+ )
255+ )
247256 elseif entry .group then
248257 local bookmark_icon , bookmark_desc = get_bookmark_info (entry .group )
249- table.insert (lines , string.format (' %sBookmark: Group %d (%s)' , bookmark_icon , entry .group , bookmark_desc ))
258+ table.insert (
259+ lines ,
260+ string.format (
261+ ' %sBookmark: Ln %d, Col %d, Group %d (%s)' ,
262+ bookmark_icon ,
263+ target_line ,
264+ entry .col or 1 ,
265+ entry .group ,
266+ bookmark_desc
267+ )
268+ )
250269 end
251270
252- table.insert (lines , string.format (' Location: Line %d, Column %d' , target_line , entry .col or 1 ))
253271 table.insert (lines , ' ' )
272+
254273 table.insert (lines , string.format (' Content (Lines %d-%d of %d):' , start_line , end_line , total_lines ))
255274 table.insert (lines , string.rep (' ─' , separator_width ))
256- table.insert (lines , ' ' )
257-
258275 table.insert (lines , ' ```' .. filetype )
259276 local max_line_width = string.len (tostring (end_line ))
260277 for i = start_line , end_line do
261278 local line_content = file_lines [i ] or ' '
262279 local is_target = (i == target_line )
263280 local line_num_str = string.format (' %' .. max_line_width .. ' d' , i )
264- local prefix = is_target and ' ' or ' '
265- local line_display = string.format (' %s%s│ %s' , prefix , line_num_str , line_content )
281+ local prefix = is_target and ' ' or ' │ '
282+ local line_display = string.format (' %s%s %s' , prefix , line_num_str , line_content )
266283 table.insert (lines , line_display )
267- if is_target and i < end_line then
268- table.insert (lines , string.rep (' ' , max_line_width + 6 ) .. ' │' )
269- end
270284 end
271285 table.insert (lines , ' ```' )
272-
273- table.insert (lines , ' ' )
274286 table.insert (lines , string.rep (' ─' , separator_width ))
275- table.insert (
276- lines ,
277- string.format (
278- ' Size: %s | Lines: %d | Modified: %s' ,
279- metadata .size or ' Unknown' ,
280- metadata .lines or total_lines ,
281- metadata .modified or ' Unknown'
282- )
283- )
287+
284288 return table.concat (lines , ' \n ' )
285289end
286290
0 commit comments