editorBrowser.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. import * as editorCommon from '../common/editorCommon.js';
  6. /**
  7. *@internal
  8. */
  9. export function isCodeEditor(thing) {
  10. if (thing && typeof thing.getEditorType === 'function') {
  11. return thing.getEditorType() === editorCommon.EditorType.ICodeEditor;
  12. }
  13. else {
  14. return false;
  15. }
  16. }
  17. /**
  18. *@internal
  19. */
  20. export function isDiffEditor(thing) {
  21. if (thing && typeof thing.getEditorType === 'function') {
  22. return thing.getEditorType() === editorCommon.EditorType.IDiffEditor;
  23. }
  24. else {
  25. return false;
  26. }
  27. }
  28. /**
  29. *@internal
  30. */
  31. export function getCodeEditor(thing) {
  32. if (isCodeEditor(thing)) {
  33. return thing;
  34. }
  35. if (isDiffEditor(thing)) {
  36. return thing.getModifiedEditor();
  37. }
  38. return null;
  39. }