{"payload":{"feedbackUrl":"https://github.com/orgs/community/discussions/53140","repo":{"id":93619165,"defaultBranch":"master","name":"chroma","ownerLogin":"alecthomas","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2017-06-07T09:47:08.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/41767?v=4","public":true,"private":false,"isOrgOwned":false},"refInfo":{"name":"","listCacheKey":"v0:1720721238.0","currentOid":""},"activityList":{"items":[{"before":"40e5e9989e976769a8c5a51f1100a667d8419736","after":"3044bf5f3204b9d87e5ee58a0511c4639c1d10bb","ref":"refs/heads/master","pushedAt":"2024-07-22T16:19:08.000Z","pushType":"pr_merge","commitsCount":1,"pusher":{"login":"alecthomas","name":"Alec Thomas","path":"/alecthomas","primaryAvatarUrl":"https://avatars.githubusercontent.com/u/41767?s=80&v=4"},"commit":{"message":"Go lexer: single line comment without consuming endline, disable EnsureNL (#984)\n\nThis PR changes `CommentSingle` to not consume the newline at the end as\r\na part of comment.\r\nThat solves the problems of single line comment being not parsed at the\r\nend of the line or at the end of the file. Which was reported earlier as\r\nthe reason to not highlight single line comment properly.\r\n\r\nDisabling `EnsureNL: true` does not add unnecessary newline element for\r\n`Text`, `CommentSymbol` symbols. Using chroma in console with syntax\r\nhighlighting was unusable becasue of this, since typing e.g. `b := `\r\nadds newline each time space is at the end when host app asks for\r\nhighlighted text from `quick`.\r\n\r\nTokens behavior:\r\n
Before | After | \r\n
\r\n\r\n``` go\r\nt.Run(\"Single space\", func(t *testing.T) {\r\n tokens, _ := chroma.Tokenise(Go, nil, \" \")\r\n expected := []chroma.Token{\r\n {chroma.Text, \" \\n\"},\r\n }\r\n assert.Equal(t, expected, tokens)\r\n})\r\nt.Run(\"Assignment unfinished\", func(t *testing.T) {\r\n tokens, _ := chroma.Tokenise(Go, nil, \"i = \")\r\n expected := []chroma.Token{\r\n { chroma.NameOther, \"i\" },\r\n { chroma.Text, \" \" },\r\n { chroma.Punctuation, \"=\" },\r\n { chroma.Text, \" \\n\" },\r\n }\r\n assert.Equal(t, expected, tokens)\r\n})\r\nt.Run(\"Single comment\", func(t *testing.T) {\r\n tokens, _ := chroma.Tokenise(Go, nil, \"// W\")\r\n expected := []chroma.Token{\r\n { chroma.CommentSingle, \"// W\\n\" },\r\n }\r\n assert.Equal(t, expected, tokens)\r\n})\r\n```\r\n\r\n | \r\n\r\n \r\n``` go\r\nt.Run(\"Single space\", func(t *testing.T) {\r\n tokens, _ := chroma.Tokenise(Go, nil, \" \")\r\n expected := []chroma.Token{\r\n {chroma.Text, \" \"},\r\n }\r\n assert.Equal(t, expected, tokens)\r\n})\r\nt.Run(\"Assignment unfinished\", func(t *testing.T) {\r\n tokens, _ := chroma.Tokenise(Go, nil, \"i = \")\r\n expected := []chroma.Token{\r\n { chroma.NameOther, \"i\" },\r\n { chroma.Text, \" \" },\r\n { chroma.Punctuation, \"=\" },\r\n { chroma.Text, \" \" },\r\n }\r\n assert.Equal(t, expected, tokens)\r\n})\r\nt.Run(\"Single comment\", func(t *testing.T) {\r\n tokens, _ := chroma.Tokenise(Go, nil, \"// W\")\r\n expected := []chroma.Token{\r\n { chroma.CommentSingle, \"// W\" },\r\n }\r\n assert.Equal(t, expected, tokens)\r\n})\r\n```\r\n | \r\n