{"version":3,"sources":["browser/monaco-diff-navigator-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;kFAckF;;AAGlF,OAAO,EAAC,aAAa,EAAC,MAAM,gBAAgB,CAAC;AAC7C,OAAO,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;AACnE,OAAO,qBAAqB,GAAG,MAAM,CAAC,MAAM,CAAC,qBAAqB,CAAC;AAEnE,qBACa,0BAA0B;IAEnC,MAAM,CAAC,aAAa,gBASlB;IAEF,oBAAoB,CAAC,MAAM,EAAE,qBAAqB,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,aAAa;CAsBtG","file":"../../src/browser/monaco-diff-navigator-factory.d.ts","sourcesContent":["/********************************************************************************\r\n * Copyright (C) 2018 TypeFox and others.\r\n *\r\n * This program and the accompanying materials are made available under the\r\n * terms of the Eclipse Public License v. 2.0 which is available at\r\n * http://www.eclipse.org/legal/epl-2.0.\r\n *\r\n * This Source Code may also be made available under the following Secondary\r\n * Licenses when the conditions for such availability set forth in the Eclipse\r\n * Public License v. 2.0 are satisfied: GNU General Public License, version 2\r\n * with the GNU Classpath Exception which is available at\r\n * https://www.gnu.org/software/classpath/license.html.\r\n *\r\n * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0\r\n ********************************************************************************/\r\n\r\nimport {injectable} from 'inversify';\r\nimport {DiffNavigator} from '@tartjs/editor';\r\nimport IStandaloneDiffEditor = monaco.editor.IStandaloneDiffEditor;\r\nimport IDiffNavigatorOptions = monaco.editor.IDiffNavigatorOptions;\r\n\r\n@injectable()\r\nexport class MonacoDiffNavigatorFactory {\r\n\r\n    static nullNavigator = <DiffNavigator>{\r\n        canNavigate: () => false,\r\n        hasNext: () => false,\r\n        hasPrevious: () => false,\r\n        next: () => {\r\n        },\r\n        previous: () => {\r\n        },\r\n        revealFirst: false,\r\n    };\r\n\r\n    createdDiffNavigator(editor: IStandaloneDiffEditor, options?: IDiffNavigatorOptions): DiffNavigator {\r\n        const navigator = monaco.editor.createDiffNavigator(editor, options);\r\n        const ensureInitialized = (fwd: boolean) => {\r\n            if (navigator.nextIdx < -1) {\r\n                navigator._initIdx(fwd);\r\n            }\r\n        };\r\n        return <DiffNavigator>{\r\n            canNavigate: () => navigator.canNavigate(),\r\n            hasNext: () => {\r\n                ensureInitialized(true);\r\n                return navigator.nextIdx + 1 < navigator.ranges.length;\r\n            },\r\n            hasPrevious: () => {\r\n                ensureInitialized(false);\r\n                return navigator.nextIdx > 0;\r\n            },\r\n            next: () => navigator.next(),\r\n            previous: () => navigator.previous(),\r\n            revealFirst: navigator.revealFirst,\r\n        };\r\n    }\r\n}\r\n"]}