22
33local M = {}
44
5- --[[ This comment is for LuaDoc.
65---
76-- Two-way file comparison for Textadept.
87--
@@ -49,24 +48,18 @@ local M = {}
4948-- Ctrl+Alt+, | ^⌘, | None | Goto previous difference
5049-- Ctrl+Alt+< | ^⌘< | None | Merge left
5150-- Ctrl+Alt+> | ^⌘> | None | Merge right
52- --
53- -- @field MARK_ADDITION (number)
54- -- The marker for line additions.
55- -- @field MARK_DELETION (number)
56- -- The marker for line deletions.
57- -- @field MARK_MODIFICATION (number)
58- -- The marker for line modifications.
59- -- @field INDIC_ADDITION (number)
60- -- The indicator number for text added within lines.
61- -- @field INDIC_DELETION (number)
62- -- The indicator number for text deleted within lines.
63- module('file_diff')]]
51+ -- @module file_diff
6452
65- M .MARK_ADDITION = _SCINTILLA .next_marker_number ()
66- M .MARK_DELETION = _SCINTILLA .next_marker_number ()
67- M .MARK_MODIFICATION = _SCINTILLA .next_marker_number ()
68- M .INDIC_ADDITION = _SCINTILLA .next_indic_number ()
69- M .INDIC_DELETION = _SCINTILLA .next_indic_number ()
53+ --- The marker for line additions.
54+ M .MARK_ADDITION = _SCINTILLA .new_marker_number ()
55+ --- The marker for line deletions.
56+ M .MARK_DELETION = _SCINTILLA .new_marker_number ()
57+ --- The marker for line modifications.
58+ M .MARK_MODIFICATION = _SCINTILLA .new_marker_number ()
59+ --- The indicator number for text added within lines.
60+ M .INDIC_ADDITION = _SCINTILLA .new_indic_number ()
61+ --- The indicator number for text deleted within lines.
62+ M .INDIC_DELETION = _SCINTILLA .new_indic_number ()
7063local MARK_ADDITION = M .MARK_ADDITION
7164local MARK_DELETION = M .MARK_DELETION
7265local MARK_MODIFICATION = M .MARK_MODIFICATION
@@ -290,7 +283,6 @@ local starting_diff = false
290283-- the user is prompted for a file.
291284-- @param horizontal Optional flag specifying whether or not to split the view horizontally. The
292285-- default value is `false`, comparing the two files side-by-side.
293- -- @name start
294286function M .start (file1 , file2 , horizontal )
295287 file1 = file1 or ui .dialogs .open {
296288 title = _L [' Select the first file to compare' ],
347339-- Jumps to the next or previous difference between the two files depending on boolean *next*.
348340-- [`file_diff.start()`]() must have been called previously.
349341-- @param next Whether to go to the next or previous difference relative to the current line.
350- -- @name goto_change
351342function M .goto_change (next )
352343 if not _VIEWS [view1 ] or not _VIEWS [view2 ] then return end
353344 -- Determine the line to start on, keeping in mind the synchronized line numbers may be different.
419410-- Merges a change from one buffer to another, depending on the change under the caret and the
420411-- merge direction.
421412-- @param left Whether to merge from right to left or left to right.
422- -- @name merge
423413function M .merge (left )
424414 if not _VIEWS [view1 ] or not _VIEWS [view2 ] then return end
425415 local buffer1 , buffer2 = view1 .buffer , view2 .buffer
@@ -534,24 +524,21 @@ for i = 1, #m_tools - 1 do
534524 elseif found_area then
535525 local label = m_tools [i ].title or m_tools [i ][1 ]
536526 if ' Compare Files' < label :gsub (' ^_' , ' ' ) or m_tools [i ][1 ] == ' ' then
537- -- LuaFormatter off
538527 table.insert (m_tools , i , {
539- title = _L [' Compare Files' ],
540- {_L [' Compare Files...' ], M .start },
541- {_L [' Compare This File With...' ], function ()
542- if buffer .filename then M .start (buffer .filename ) end
543- end },
544- {_L [' Compare Buffers' ], function () M .start (' -' , ' -' ) end },
545- {' ' },
528+ title = _L [' Compare Files' ], --
529+ {_L [' Compare Files...' ], M .start }, {
530+ _L [' Compare This File With...' ],
531+ function () if buffer .filename then M .start (buffer .filename ) end end
532+ }, {_L [' Compare Buffers' ], function () M .start (' -' , ' -' ) end }, --
533+ {' ' }, --
546534 {_L [' Next Change' ], function () M .goto_change (true ) end },
547- {_L [' Previous Change' ], M .goto_change },
548- {' ' },
549- {_L [' Merge Left' ], function () M .merge (true ) end },
550- {_L [' Merge Right' ], M .merge },
551- {' ' },
535+ {_L [' Previous Change' ], M .goto_change }, --
536+ {' ' }, --
537+ {_L [' Merge Left' ], function () M .merge (true ) end }, --
538+ {_L [' Merge Right' ], M .merge }, --
539+ {' ' }, --
552540 {_L [' Stop Comparing' ], stop }
553541 })
554- -- LuaFormatter on
555542 break
556543 end
557544 end
569556
570557return M
571558
572- --[[ The function below is a Lua C function.
559+ -- The function below is a Lua C function.
560+
573561---
574562-- Returns a list that represents the differences between strings *text1* and *text2*.
575563-- Each consecutive pair of elements in the returned list represents a "diff". The first element
@@ -580,5 +568,4 @@ return M
580568-- @return list of differences
581569-- @usage diffs = diff(text1, text2)
582570-- for i = 1, #diffs, 2 do print(diffs[i], diffs[i + 1]) end
583- function _G.diff(text1, text2) end
584- ]]
571+ -- @function _G.diff
0 commit comments