Skip to content

Commit

Permalink
Fix grammar specs (don't trim the start of the line!)
Browse files Browse the repository at this point in the history
  • Loading branch information
savetheclocktower committed Jan 16, 2025
1 parent 159542a commit bc1c2e1
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions vendor/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -2719,21 +2719,18 @@ jasmine.Matchers.prototype.toSatisfy = function(fn) {
function normalizeTreeSitterTextData(editor, commentRegex, trailingCommentRegex) {
let allMatches = [], lastNonComment = 0
const checkAssert = new RegExp('^\\s*' + commentRegex.source + '\\s*[\\<\\-|\\^]')
console.log('editor:', editor.getText());
console.log('checkAssert', checkAssert);
editor.getBuffer().getLines().forEach((row, i) => {
const m = row.match(commentRegex)
console.log('does it match?', row, m);
if (m) {
if (trailingCommentRegex) {
row = row.replace(trailingCommentRegex, '')
}
row = row.trim()
// Strip extra space at the end of the line (but not the beginning!)
row = row.replace(/\s+$/, '')
// const scope = editor.scopeDescriptorForBufferPosition([i, m.index])
// FIXME: use editor.scopeDescriptorForBufferPosition when it works
const scope = editor.tokensForScreenRow(i)
const scopes = scope.flatMap(e => e.scopes)
console.log('scopes:', scopes);
if (scopes.find(s => s.match(/comment/)) && row.match(checkAssert)) {
allMatches.push({row: lastNonComment, text: row, col: m.index, testRow: i})
return
Expand Down Expand Up @@ -2773,7 +2770,6 @@ async function runGrammarTests(fullPath, commentRegex, trailingCommentRegex = nu
const editor = await openDocument(fullPath);

const normalized = normalizeTreeSitterTextData(editor, commentRegex, trailingCommentRegex)
console.log('normalized', normalized);
expect(normalized.length).toSatisfy((n, reason) => {
reason("Tokenizer didn't run correctly - could not find any comment")
return n > 0
Expand Down

0 comments on commit bc1c2e1

Please sign in to comment.