Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/src/actions/preview.js b/src/actions/preview.js
- index b0f39b3..981410c 100644
- --- a/src/actions/preview.js
- +++ b/src/actions/preview.js
- @@ -80,13 +80,6 @@ export function updatePreview(target: HTMLElement, editor: any) {
- }
- }
- - const source = getSelectedSource(getState());
- -
- - const symbols = getSymbols(getState(), source.toJS());
- - if (symbols.functions.length == 0) {
- - return;
- - }
- -
- const invalidToken =
- tokenText === "" || tokenText.match(/[(){}\|&%,.;=<>\+-/\*\s]/);
- @@ -115,13 +108,22 @@ export function updatePreview(target: HTMLElement, editor: any) {
- return;
- }
- - dispatch(setPreview(tokenText, location, cursorPos));
- + const source = getSelectedSource(getState());
- + const symbols = getSymbols(getState(), source.toJS());
- +
- + let expression;
- + if (!symbols.function) {
- + expression = fastPreview(target, editor);
- + } else {
- + expression = findBestMatchExpression(symbols, tokenPos, token);
- + }
- +
- + dispatch(setPreview(expression, cursorPos));
- };
- }
- export function setPreview(
- - token: string,
- - tokenPos: AstLocation,
- + expression: { expression: String, location: Location },
- cursorPos: any
- ) {
- return async ({ dispatch, getState, client, sourceMaps }: ThunkArgs) => {
- @@ -133,16 +135,6 @@ export function setPreview(
- await dispatch({
- type: "SET_PREVIEW",
- [PROMISE]: (async function() {
- - const source = getSelectedSource(getState());
- - const symbols = getSymbols(getState(), source.toJS());
- - const found = findBestMatchExpression(symbols, tokenPos, token);
- -
- - if (!found) {
- - return;
- - }
- -
- - let { expression, location } = found;
- -
- if (!expression) {
- return;
- }
Add Comment
Please, Sign In to add comment