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

(JS mode): (pressing enter before /** erroneously inserts *) #5320

Closed
nightwing opened this issue Sep 21, 2023 · 3 comments
Closed

(JS mode): (pressing enter before /** erroneously inserts *) #5320

nightwing opened this issue Sep 21, 2023 · 3 comments

Comments

@nightwing
Copy link
Member

nightwing commented Sep 21, 2023

press enter before doc comment in js mode

@marinsokol5
Copy link
Contributor

Can confirm the experience
ace-js-bug-2

@marinsokol5 marinsokol5 added the p2 label Sep 22, 2023
@marinsokol5
Copy link
Contributor

Problem is somewhere in CStyle behaviour

this.add("doc comment end", "insertion", function (state, action, editor, session, text) {
if (state === "doc-start" && (text === "\n" || text === "\r\n") && editor.selection.isEmpty()) {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var nextLine = session.doc.getLine(cursor.row + 1);
var indent = this.$getIndent(line);
if (/\s*\*/.test(nextLine)) {
if (/^\s*\*/.test(line)) {
return {
text: text + indent + "* ",
selection: [1, 3 + indent.length, 1, 3 + indent.length]
};
}
else {
return {
text: text + indent + " * ",
selection: [1, 3 + indent.length, 1, 3 + indent.length]
};
}
}
if (/\/\*\*/.test(line.substring(0, cursor.column))) {
return {
text: text + indent + " * " + text + " " + indent + "*/",
selection: [1, 4 + indent.length, 1, 4 + indent.length]
};
}
}

It's likely not a super big change to do but this file is quite important as it's imported by text mode as a default behaviour, so it's likely affecting a large deal of modes, not just Javascript.

There are some tests though in

"test: doc comment auto-closing": function() {

@InspiredGuy
Copy link
Contributor

#5571 with the fix was merged, will be available in the next release

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

No branches or pull requests

3 participants