Skip to content

Commit

Permalink
Merge pull request #16498 from iterate-ch/bugfix/GH-12897
Browse files Browse the repository at this point in the history
Fix #12897. Make sure to ignore file system events from monitored col…
  • Loading branch information
dkocher authored Nov 15, 2024
2 parents 3845480 + 94cccca commit 40249a7
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 23 deletions.
13 changes: 11 additions & 2 deletions core/src/main/java/ch/cyberduck/core/Collection.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,17 @@ public void add(int row, E item) {
this.collectionItemAdded(item);
}

public void replace(int row, E item) {
this.set(row, item);
public E set(int row, E item) {
final E previous = super.set(row, item);
for(CollectionListener<E> listener : listeners) {
listener.collectionItemChanged(item);
}
return previous;
}

public void move(int from, int to) {
final E item = super.remove(from);
this.add(to, item);
for(CollectionListener<E> listener : listeners) {
listener.collectionItemChanged(item);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public void fileWritten(final Local file) {
// Found bookmark with matching UUID
if(new HostEditComparator().compare(bookmark, this.get(index)) != 0) {
log.debug("Replace bookmark {} at index {}", bookmark, index);
this.replace(index, bookmark);
this.set(index, bookmark);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -424,20 +424,13 @@ else if(!pasteboard.isEmpty()) {
else {
int insert = row.intValue();
for(Host bookmark : pasteboard) {
int previous = source.indexOf(bookmark);
if(previous == insert) {
int sourceIndex = source.indexOf(bookmark);
if(sourceIndex == insert) {
// No need to move
continue;
}
source.remove(previous);
int moved;
if(previous < insert) {
moved = insert - 1;
}
else {
moved = insert;
}
source.add(moved, bookmark);
int destIndex = sourceIndex < insert ? insert - 1 : insert;
source.move(sourceIndex, destIndex);
}
for(Host bookmark : pasteboard) {
int index = source.indexOf(bookmark);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -751,15 +751,7 @@ private void View_HostModelDropped(ModelDropEventArgs dropargs)
}
foreach (Host promisedDragBookmark in dropargs.SourceModels)
{
_bookmarkModel.Source.remove(promisedDragBookmark);
if (destIndex > _bookmarkModel.Source.size())
{
_bookmarkModel.Source.add(promisedDragBookmark);
}
else
{
_bookmarkModel.Source.add(destIndex, promisedDragBookmark);
}
_bookmarkModel.Source.move(sourceIndex, destIndex);
//view.selectRowIndexes(NSIndexSet.indexSetWithIndex(row), false);
//view.scrollRowToVisible(row);
}
Expand Down

0 comments on commit 40249a7

Please sign in to comment.