Guest User

Untitled

a guest
Feb 22nd, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. diff --git a/src/actions/preview.js b/src/actions/preview.js
  2. index b0f39b3..981410c 100644
  3. --- a/src/actions/preview.js
  4. +++ b/src/actions/preview.js
  5. @@ -80,13 +80,6 @@ export function updatePreview(target: HTMLElement, editor: any) {
  6. }
  7. }
  8.  
  9. - const source = getSelectedSource(getState());
  10. -
  11. - const symbols = getSymbols(getState(), source.toJS());
  12. - if (symbols.functions.length == 0) {
  13. - return;
  14. - }
  15. -
  16. const invalidToken =
  17. tokenText === "" || tokenText.match(/[(){}\|&%,.;=<>\+-/\*\s]/);
  18.  
  19. @@ -115,13 +108,22 @@ export function updatePreview(target: HTMLElement, editor: any) {
  20. return;
  21. }
  22.  
  23. - dispatch(setPreview(tokenText, location, cursorPos));
  24. + const source = getSelectedSource(getState());
  25. + const symbols = getSymbols(getState(), source.toJS());
  26. +
  27. + let expression;
  28. + if (!symbols.function) {
  29. + expression = fastPreview(target, editor);
  30. + } else {
  31. + expression = findBestMatchExpression(symbols, tokenPos, token);
  32. + }
  33. +
  34. + dispatch(setPreview(expression, cursorPos));
  35. };
  36. }
  37.  
  38. export function setPreview(
  39. - token: string,
  40. - tokenPos: AstLocation,
  41. + expression: { expression: String, location: Location },
  42. cursorPos: any
  43. ) {
  44. return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
  45. @@ -133,16 +135,6 @@ export function setPreview(
  46. await dispatch({
  47. type: "SET_PREVIEW",
  48. [PROMISE]: (async function() {
  49. - const source = getSelectedSource(getState());
  50. - const symbols = getSymbols(getState(), source.toJS());
  51. - const found = findBestMatchExpression(symbols, tokenPos, token);
  52. -
  53. - if (!found) {
  54. - return;
  55. - }
  56. -
  57. - let { expression, location } = found;
  58. -
  59. if (!expression) {
  60. return;
  61. }
Add Comment
Please, Sign In to add comment