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

fix: don't add additional asterisks in c style docs #5323

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marinsokol5
Copy link
Contributor

@marinsokol5 marinsokol5 commented Sep 22, 2023

Issue #, if available:
#5320

Description of changes:

  • now we check if the cursor is before the doc starts or after it, if it's after then we have doc mode as usual, but if the cursor is before then we don't do anything.
  • Current experience, notice the problem anytime a cursor is behind an "*" sign:
    current-ace-cdocs
  • New experience
    c-style-new

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov
Copy link

codecov bot commented Sep 22, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (f401013) 87.38% compared to head (d52d9b3) 87.38%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5323   +/-   ##
=======================================
  Coverage   87.38%   87.38%           
=======================================
  Files         574      574           
  Lines       45534    45542    +8     
  Branches     6935     6935           
=======================================
+ Hits        39788    39796    +8     
  Misses       5746     5746           
Flag Coverage Δ
unittests 87.38% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Changed Coverage Δ
src/mode/behaviour/behaviour_test.js 99.43% <100.00%> (+0.01%) ⬆️
src/mode/behaviour/cstyle.js 89.84% <100.00%> (+0.03%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -311,7 +311,8 @@ var CstyleBehaviour = function(options) {
var line = session.doc.getLine(cursor.row);
var nextLine = session.doc.getLine(cursor.row + 1);
var indent = this.$getIndent(line);
if (/\s*\*/.test(nextLine)) {
const beforeCursor = line.substring(0, cursor.column);
if (/\s*\*/.test(nextLine) && /\*/.test(beforeCursor)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this match a * b /**comment*/ with cursor before the comment ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I don't think so because we still check if there is an * in next line, so I guess it would match:

a * b /**<cursor>comment*/
*

Which would be turned into

a * b /**
* <cursor>comment*/
*

I think, but let me double check this. Nice test example!!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah so actually nothing cool happens because state is not "doc-start", so it just goes into new line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, my bad for including */ in the end of the example. In default js example of this pull request https://raw.githack.com/ajaxorg/ace/d52d9b32e5eb23a2a1981bf2b10344ede05b2214/kitchen-sink.html, if i press enter at the start of the file, the bug is indeed fixed, but if i type * at the start and only then press enter the comment indentation is applied.
We either need to test for a more specific pattern, or compute the state in the middle of line like outdent does.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@marinsokol5 I could reproduce the issue highlighted by @nightwing, could you please take a look into it and update your PR to address it?

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

Successfully merging this pull request may close these issues.

None yet

4 participants