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
12 changes: 12 additions & 0 deletions embedding/commentfilter/c_style_filter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,16 @@ var _ = Describe("C and C++", func() {

assertFiltered("sample.hpp", RetainBlock, lines, expected)
})

It("should not close block comments on an overlapping end marker", func() {
lines := []string{
"int before = 1; /*/ still comment */ int after = 2;",
}

expected := []string{
"int before = 1; int after = 2;",
}

assertFiltered("sample.cpp", RetainNone, lines, expected)
})
})
16 changes: 3 additions & 13 deletions embedding/commentfilter/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ const (
pythonSingleQuoteBlock = "'''"
goRawStringDelimiter = "`"
goQuoteChars = "\"'"
jsQuoteChars = "\"'`"
)

// filtersByExtension is a mapping of the file extension to its comment filter.
Expand Down Expand Up @@ -64,9 +63,9 @@ var filtersByExtension = map[string]filterEntry{
".proto": filterConfig(MarkerCommentFilter{Syntax: cStyleSyntax}, regularModes),

// Python
".py": filterConfig(MarkerCommentFilter{Syntax: pythonSyntax}, noneMode),
".pyi": filterConfig(MarkerCommentFilter{Syntax: pythonSyntax}, noneMode),
".pyw": filterConfig(MarkerCommentFilter{Syntax: pythonSyntax}, noneMode),
".py": filterConfig(PythonCommentFilter{}, noneMode),
".pyi": filterConfig(PythonCommentFilter{}, noneMode),
".pyw": filterConfig(PythonCommentFilter{}, noneMode),

// YAML
".yml": filterConfig(MarkerCommentFilter{Syntax: hashLineSyntax}, noneMode),
Expand Down Expand Up @@ -133,15 +132,6 @@ var hashLineSyntax = CommentMarker{
QuoteChars: "\"'",
}

var pythonSyntax = CommentMarker{
Inline: []string{"#"},
TextBlocks: []TextBlockMarker{
{Delimiter: pythonDoubleQuoteBlock, Escapes: true},
{Delimiter: pythonSingleQuoteBlock, Escapes: true},
},
QuoteChars: "\"'",
}

var xmlSyntax = CommentMarker{
Block: []BlockMarker{
{Start: "<!--", End: "-->"},
Expand Down
Loading
Loading