Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,6 @@ Toliver <[email protected]>
Toni Müller <[email protected]>
Tyler Jones <[email protected]>
Uku Pattak <[email protected]>
Wylie Conlon <[email protected]>
Xin Hu <[email protected]>
Zhongxian Liang <[email protected]>
4 changes: 2 additions & 2 deletions src/lexer/NestedComment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import { RegExpLike } from './TokenizerEngine.js';

const START = /\/\*/uy; // matches: /*
const MIDDLE = /([^/*]|\*[^/]|\/[^*])+/uy; // matches text NOT containing /* or */
const ANY_CHAR = /[\s\S]/uy; // matches single character
const END = /\*\//uy; // matches: */

/**
Expand Down Expand Up @@ -31,7 +31,7 @@ export class NestedComment implements RegExpLike {
} else if ((match = this.matchSection(END, input))) {
result += match;
nestLevel--;
} else if ((match = this.matchSection(MIDDLE, input))) {
} else if ((match = this.matchSection(ANY_CHAR, input))) {
result += match;
} else {
return null;
Expand Down
6 changes: 6 additions & 0 deletions test/features/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ export default function supportsComments(format: FormatFn, opts: CommentsConfig
`);
});

// Regression test for #747
it('handles block comments with /** and **/ patterns', () => {
const sql = `/** This is a block comment **/`;
expect(format(sql)).toBe(sql);
});

if (opts.hashComments) {
it('supports # line comment', () => {
const result = format('SELECT alpha # commment\nFROM beta');
Expand Down