Guest User

Untitled

a guest
Dec 11th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. diff --git a/src/components/Editor/index.js b/src/components/Editor/index.js
  2. index 90468a5..88714ca 100644
  3. --- a/src/components/Editor/index.js
  4. +++ b/src/components/Editor/index.js
  5. @@ -100,15 +100,10 @@ type State = {
  6. class Editor extends PureComponent<Props, State> {
  7. cbPanel: any;
  8. editor: SourceEditor;
  9. - pendingJumpLocation: any;
  10. - lastJumpLine: any;
  11.  
  12. constructor() {
  13. super();
  14.  
  15. - this.pendingJumpLocation = null;
  16. - this.lastJumpLine = null;
  17. -
  18. this.state = {
  19. highlightedLineRange: null,
  20. editor: null
  21. @@ -200,10 +195,6 @@ class Editor extends PureComponent<Props, State> {
  22. shortcuts.on(searchAgainPrevKey, this.onSearchAgain);
  23. shortcuts.on(searchAgainKey, this.onSearchAgain);
  24.  
  25. - if (selectedLocation && !!selectedLocation.line) {
  26. - this.pendingJumpLocation = selectedLocation;
  27. - }
  28. -
  29. const sourceId = selectedSource ? selectedSource.get("id") : undefined;
  30. updateDocument(editor, sourceId);
  31. }
  32. @@ -234,19 +225,6 @@ class Editor extends PureComponent<Props, State> {
  33. // responsible for updating the editor annotations.
  34. const { selectedLocation, selectedSource } = this.props;
  35.  
  36. - // If the location is different and a new line is requested,
  37. - // update the pending jump line. Note that if jumping to a line in
  38. - // a source where the text hasn't been loaded yet, we will set the
  39. - // line here but not jump until rendering the actual source.
  40. -
  41. - if (prevProps.selectedLocation !== selectedLocation) {
  42. - if (selectedLocation && selectedLocation.line != undefined) {
  43. - this.pendingJumpLocation = selectedLocation;
  44. - } else {
  45. - this.pendingJumpLocation = null;
  46. - }
  47. - }
  48. -
  49. // NOTE:
  50. // 1. Only update and jump around in real source texts. This will
  51. // keep the jump state around until the real source text is loaded.
  52. @@ -423,42 +401,22 @@ class Editor extends PureComponent<Props, State> {
  53. return this.props.closeConditionalPanel();
  54. };
  55.  
  56. - // If the location has changed and a specific line is requested,
  57. - // move to that line and flash it.
  58. - highlightLine() {
  59. - const { selectedLocation, selectedFrame } = this.props;
  60. - if (!selectedLocation) {
  61. - return;
  62. - }
  63. -
  64. - // Make sure to clean up after ourselves. Not only does this
  65. - // cancel any existing animation, but it avoids it from
  66. - // happening ever again (in case CodeMirror re-applies the
  67. - // class, etc).
  68. - if (this.lastJumpLine !== null) {
  69. - clearLineClass(this.state.editor.codeMirror, "highlight-line");
  70. - }
  71. -
  72. - let line = null;
  73. - if (selectedLocation.line >= 0) {
  74. - line = this.scrollToPosition();
  75. - }
  76. + scrollToLocation() {
  77. + this.scrollToPosition();
  78. + }
  79.  
  80. - // We only want to do the flashing animation if it's not a debug
  81. - // line, which has it's own styling.
  82. - // Also, if it the first time the debugger is being loaded, we don't want
  83. - // to flash the previously saved selected line.
  84. - if (
  85. - line !== null &&
  86. - this.lastJumpLine !== null &&
  87. - this.lastJumpLine !== line &&
  88. - (!selectedFrame || selectedFrame.location.line !== line)
  89. - ) {
  90. - this.state.editor.codeMirror.addLineClass(line, "line", "highlight-line");
  91. - }
  92. + clearHighlightLine() {
  93. + clearLineClass(this.state.editor.codeMirror, "highlight-line");
  94. + }
  95.  
  96. - this.lastJumpLine = line;
  97. - this.pendingJumpLocation = null;
  98. + highlightLine() {
  99. + const { sourceId, line } = this.props.selectedLocation;
  100. + const editorLine = toEditorLine(sourceId, line);
  101. + this.state.editor.codeMirror.addLineClass(
  102. + editorLine,
  103. + "line",
  104. + "highlight-line"
  105. + );
  106. }
  107.  
  108. scrollToPosition() {
Add Comment
Please, Sign In to add comment