Skip to content

Commit b58957e

Browse files
authored
Improve readability/quality of #211741 (#211758)
readability improvements
1 parent e5eb53a commit b58957e

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/outline/notebookOutline.ts

+13-14
Original file line numberDiff line numberDiff line change
@@ -301,22 +301,21 @@ class NotebookQuickPickProvider implements IQuickPickDataSource<OutlineEntry> {
301301
const { hasFileIcons } = this._themeService.getFileIconTheme();
302302

303303
const showSymbols = this._configurationService.getValue<boolean>(NotebookSetting.gotoSymbolsAllSymbols);
304+
const isSymbol = (element: OutlineEntry) => !!element.symbolKind;
305+
const isCodeCell = (element: OutlineEntry) => (element.cell.cellKind === CellKind.Code && element.level === NotebookOutlineConstants.NonHeaderOutlineLevel); // code cell entries are exactly level 7 by this constant
304306
for (let i = 0; i < bucket.length; i++) {
305307
const element = bucket[i];
306-
const nextElement = bucket[i + 1];
307-
308-
// this logic controls the following for code cells entries in quick pick:
309-
if (element.cell.cellKind === CellKind.Code) {
310-
// if we are showing all symbols, and
311-
// - the next entry is a symbol, we DO NOT include the code cell entry (ie continue)
312-
// - the next entry is not a symbol, we DO include the code cell entry (ie push as normal in the loop)
313-
if (showSymbols && element.level === NotebookOutlineConstants.NonHeaderOutlineLevel && (nextElement?.level > NotebookOutlineConstants.NonHeaderOutlineLevel)) {
314-
continue;
315-
}
316-
// if we are not showing all symbols, skip all entries with level > NonHeaderOutlineLevel (ie 8+)
317-
else if (!showSymbols && element.level > NotebookOutlineConstants.NonHeaderOutlineLevel) {
318-
continue;
319-
}
308+
const nextElement = bucket[i + 1]; // can be undefined
309+
310+
if (!showSymbols
311+
&& isSymbol(element)) {
312+
continue;
313+
}
314+
315+
if (showSymbols
316+
&& isCodeCell(element)
317+
&& nextElement && isSymbol(nextElement)) {
318+
continue;
320319
}
321320

322321
const useFileIcon = hasFileIcons && !element.symbolKind;

0 commit comments

Comments
 (0)