Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functionality to remove specific files from Recent Files #2035

Merged
merged 5 commits into from
Jan 9, 2025
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 46 additions & 7 deletions src/extensionsIntegrated/NavigationAndHistory/main.js
Original file line number Diff line number Diff line change
@@ -221,7 +221,7 @@ define(function (require, exports, module) {
}

function _createFileEntries($mrofList) {
var data, fileEntry, $link, $newItem;
var data, fileEntry, $link, $newItem, $removeBtn;
// Iterate over the MROF list and create the pop over UI items

// If we are in split view we might want to show the panes corresponding to the entries
@@ -239,33 +239,72 @@ define(function (require, exports, module) {
// Try to see if we have same doc split
// Check existing list for this doc path and active pane entry
var entryIndex = _.findIndex(_mrofList, function (record) {
return (record && record.file === value.file && record.paneId === MainViewManager.getActivePaneId());
return (
record &&
record.file === value.file &&
record.paneId === MainViewManager.getActivePaneId()
);
});

// If found don't process this entry, as the document is already present in active pane
if (entryIndex >= 0) {
return true;
}
// Process this for active pane id
// Process this for active pane id
value.paneId = MainViewManager.getActivePaneId();

}

var indxInWS = MainViewManager.findInWorkingSet(value.paneId, value.file);

data = {fullPath: value.file,
data = {
fullPath: value.file,
name: FileUtils.getBaseName(value.file),
isFile: true};
isFile: true
};

fileEntry = FileSystem.getFileForPath(value.file);

// Create new list item with a link
$link = $("<a href='#' class='mroitem'></a>").html(ViewUtils.getFileEntryDisplay({name: FileUtils.getBaseName(value.file)}));
$link = $("<a href='#' class='mroitem'></a>").html(
ViewUtils.getFileEntryDisplay({name: FileUtils.getBaseName(value.file)})
);

// Create remove button only for files not in working set
$removeBtn = null;
if (indxInWS === -1) {
$removeBtn = $("<span class='remove-file'>&times;</span>").on("click", function(e) {
e.preventDefault();
e.stopPropagation();

// Find and remove the entry from _mrofList
var filePath = $(this).parent().data("path");
var paneId = $(this).parent().data("paneId");

_mrofList = _mrofList.filter(function(entry) {
return !(entry && entry.file === filePath && entry.paneId === paneId);
});

// Remove the list item from UI
$(this).parent().remove();

// Update preferences
PreferencesManager.setViewState(
OPEN_FILES_VIEW_STATE,
_mrofList,
PreferencesManager.STATE_PROJECT_CONTEXT
);
});
}

// Use the file icon providers
WorkingSetView.useIconProviders(data, $link);

// Create list item with link and conditionally add remove button
$newItem = $("<li></li>").append($link);
if ($removeBtn) {
$newItem.append($removeBtn);
}

if (indxInWS !== -1) { // in working set show differently
$newItem.addClass("working-set");
@@ -285,7 +324,7 @@ define(function (require, exports, module) {
// Use the class providers(git e.t.c)
WorkingSetView.useClassProviders(data, $newItem);

// If a file is dirty , mark it in the list
// If a file is dirty, mark it in the list
if (_isOpenAndDirty(fileEntry)) {
$(dirtyDotTemplate).prependTo($newItem);
}
27 changes: 27 additions & 0 deletions src/styles/Extn-NavigationAndHistory.less
Original file line number Diff line number Diff line change
@@ -236,4 +236,31 @@
#mrof-container .footer {
background-color: #2c2c2c;
border-top: 1px solid #343434;
}

#mrof-list li {
position: relative;
}

.remove-file {
color: #adb9bd;
position: absolute;
right: 8px;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
opacity: 0.6;
font-size: 20px;
font-weight: 500;
display: none;
}

#mrof-list li:hover .remove-file {
color: #fff;
display: block;
}

.remove-file:hover {
color: #fff;
opacity: 1;
}