Fix/prev next links issue (#10523)

* intital test code

* added tests

* remove commented code

* fix for failing tests

* reuse exported enum

* changes to address comments

* add back onVisibility highlight

* port highlight fix from Chris

* fix tests
This commit is contained in:
Maddy
2020-06-12 18:42:17 -07:00
committed by GitHub
parent c9569d8573
commit 26a00696d4
11 changed files with 138 additions and 74 deletions

View File

@@ -34,6 +34,16 @@ export interface ILanguageMagic {
executionTarget?: string;
}
/**
* Valid navigation providers.
*/
export enum NavigationProviders {
NotebooksNavigator = 'BookNavigator.Notebooks',
ProvidedBooksNavigator = 'BookNavigator.ProvidedBooks'
}
export const unsavedBooksContextKey = 'unsavedBooks';
export interface INotebookService {
_serviceBrand: undefined;

View File

@@ -10,7 +10,7 @@ import { Registry } from 'vs/platform/registry/common/platform';
import {
INotebookService, INotebookManager, INotebookProvider,
DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, INavigationProvider, ILanguageMagic
DEFAULT_NOTEBOOK_FILETYPE, INotebookEditor, SQL_NOTEBOOK_PROVIDER, INavigationProvider, ILanguageMagic, NavigationProviders, unsavedBooksContextKey
} from 'sql/workbench/services/notebook/browser/notebookService';
import { RenderMimeRegistry } from 'sql/workbench/services/notebook/browser/outputs/registry';
import { standardRendererFactories } from 'sql/workbench/services/notebook/browser/outputs/factories';
@@ -36,6 +36,7 @@ import { NotebookChangeType } from 'sql/workbench/services/notebook/common/contr
import { find, firstIndex } from 'vs/base/common/arrays';
import { onUnexpectedError } from 'vs/base/common/errors';
import { notebookConstants } from 'sql/workbench/services/notebook/browser/interfaces';
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
export interface NotebookProviderProperties {
provider: string;
@@ -115,7 +116,8 @@ export class NotebookService extends Disposable implements INotebookService {
@IInstantiationService private _instantiationService: IInstantiationService,
@IFileService private readonly _fileService: IFileService,
@ILogService private readonly _logService: ILogService,
@IQueryManagementService private readonly _queryManagementService: IQueryManagementService
@IQueryManagementService private readonly _queryManagementService: IQueryManagementService,
@IContextKeyService private contextKeyService: IContextKeyService,
) {
super();
this._providersMemento = new Memento('notebookProviders', this._storageService);
@@ -220,7 +222,11 @@ export class NotebookService extends Disposable implements INotebookService {
}
getNavigationProvider(): INavigationProvider {
let provider = this._navigationProviders.size > 0 ? this._navigationProviders.values().next().value : undefined;
let provider;
if (this._navigationProviders.size > 0) {
const providerName = this.contextKeyService.getContextKeyValue(unsavedBooksContextKey) ? NavigationProviders.ProvidedBooksNavigator : NavigationProviders.NotebooksNavigator;
provider = this._navigationProviders.get(providerName);
}
return provider;
}