|
49 | 49 | local M = {} |
50 | 50 |
|
51 | 51 | --- The marker for line additions. |
52 | | -M.MARK_ADDITION = _SCINTILLA.new_marker_number() |
| 52 | +M.MARK_ADDITION = view.new_marker_number() |
53 | 53 | --- The marker for line deletions. |
54 | | -M.MARK_DELETION = _SCINTILLA.new_marker_number() |
| 54 | +M.MARK_DELETION = view.new_marker_number() |
55 | 55 | --- The marker for line modifications. |
56 | | -M.MARK_MODIFICATION = _SCINTILLA.new_marker_number() |
| 56 | +M.MARK_MODIFICATION = view.new_marker_number() |
57 | 57 | --- The indicator number for text added within lines. |
58 | | -M.INDIC_ADDITION = _SCINTILLA.new_indic_number() |
| 58 | +M.INDIC_ADDITION = view.new_indic_number() |
59 | 59 | --- The indicator number for text deleted within lines. |
60 | | -M.INDIC_DELETION = _SCINTILLA.new_indic_number() |
| 60 | +M.INDIC_DELETION = view.new_indic_number() |
61 | 61 | local MARK_ADDITION = M.MARK_ADDITION |
62 | 62 | local MARK_DELETION = M.MARK_DELETION |
63 | 63 | local MARK_MODIFICATION = M.MARK_MODIFICATION |
@@ -295,12 +295,12 @@ local starting_diff = false |
295 | 295 | function M.start(file1, file2, horizontal) |
296 | 296 | file1 = file1 or ui.dialogs.open{ |
297 | 297 | title = _L['Select the first file to compare'], |
298 | | - dir = (buffer.filename or ''):match('^.+[/\\]') or lfs.currentdir() |
| 298 | + dir = (buffer.filename or ''):match('^(.+)[/\\]') or lfs.currentdir() |
299 | 299 | } |
300 | 300 | if not file1 then return end |
301 | 301 | file2 = file2 or ui.dialogs.open{ |
302 | 302 | title = string.format('%s %s', _L['Select the file to compare to'], file1:match('[^/\\]+$')), |
303 | | - dir = file1:match('^.+[/\\]') or lfs.currentdir() |
| 303 | + dir = file1:match('^(.+)[/\\]') or lfs.currentdir() |
304 | 304 | } |
305 | 305 | if not file2 then return end |
306 | 306 | starting_diff = true |
@@ -338,9 +338,11 @@ events.connect(events.BUFFER_DELETED, stop) |
338 | 338 | -- @return line |
339 | 339 | local function get_synchronized_line(line) |
340 | 340 | local visible_line = view:visible_from_doc_line(line) |
| 341 | + local pos = buffer.current_pos |
341 | 342 | ui.goto_view(view == view1 and view2 or view1) |
342 | 343 | line = view:doc_line_from_visible(visible_line) |
343 | 344 | ui.goto_view(view == view2 and view1 or view2) |
| 345 | + buffer:set_empty_selection(pos) |
344 | 346 | return line |
345 | 347 | end |
346 | 348 |
|
@@ -431,9 +433,10 @@ function M.merge(left) |
431 | 433 | local line = get_synchronized_line(start_line) + 1 |
432 | 434 | if (view == view1 and buffer2 or buffer1):marker_get(line) & diff_marker > 0 then |
433 | 435 | ui.goto_view(view == view1 and view2 or view1) |
434 | | - buffer:line_down() |
| 436 | + buffer:set_empty_selection(buffer:position_from_line(line)) |
435 | 437 | M.merge(left) |
436 | 438 | ui.goto_view(view == view2 and view1 or view2) |
| 439 | + buffer:set_empty_selection(buffer:position_from_line(start_line)) |
437 | 440 | end |
438 | 441 | return |
439 | 442 | end |
@@ -466,7 +469,6 @@ function M.merge(left) |
466 | 469 | start_line = get_synchronized_line(start_line) |
467 | 470 | end_line = get_synchronized_line(end_line) |
468 | 471 | ui.goto_view(view == view1 and view2 or view1) |
469 | | - if buffer.annotation_text[end_line] ~= '' then end_line = end_line + 1 end |
470 | 472 | buffer.target_start = buffer:position_from_line(start_line) |
471 | 473 | buffer.target_end = buffer:position_from_line(end_line) |
472 | 474 | if view == view2 and left or view == view1 and not left then |
|
0 commit comments