Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

js2r-contract-node-at-point not behaving as expected #107

Open
jaredwindover opened this issue Nov 27, 2017 · 1 comment
Open

js2r-contract-node-at-point not behaving as expected #107

jaredwindover opened this issue Nov 27, 2017 · 1 comment

Comments

@jaredwindover
Copy link

class A {
    f() {
	var a = {
	    b: 1,
	    c: 'def'
	};
    };
};

If I place my cursor at the front of the word 'b' in the above block, and I execute js2r-contract-node-at-point, I receive the following:

class A {
    f() {
	var a = { b: 1, c: 'def'
 };
    };
};

Calling it again from the same spot returns the expected output:

class A {
    f() {
	var a = { b: 1, c: 'def' };
    };
};

I assumed it was due to some cutomization I'd made, but decided to try it without any of my startup scripts today and got that result.

@jaredwindover
Copy link
Author

I'm using tabs and spaces, and that seems to be sufficient to cause the problem. The following is tab indented once, and uses spaces for alignment:

	var a = {
	    b: 1,
	    c: 'def'
	};

It results in:

	var a = { b: 1, c: 'def'
 };

It seems the problem is with js2r--ensure-just-one-space. Executing from behind the curly brace with the below string:


	};

results in:


 };

whereas it should clear the newline (and does if it's spaces instead of a tab).

This is the function that's being called:

(defun js2r--ensure-just-one-space ()
  (interactive)
  (while (or (looking-at "\s*\n")
             (looking-back "\n\s*"))
    (when (looking-at "\n")
      (delete-char 1))
    (when (looking-back "\n\s")
      (backward-char)
      (delete-char -1))
    (just-one-space))
(just-one-space))

Is \s in those regexs matching a single space, or all whitespace characters?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant