Skip to content

Commit

Permalink
Fix bug in syntax highlighting caused by incorrect function call (Mar…
Browse files Browse the repository at this point in the history
  • Loading branch information
david-yz-liu authored Aug 27, 2024
1 parent e8d28f2 commit a620c5b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

### 🐛 Bug fixes

- Fix bug in syntax highlighting caused by incorrect function call (#7187)

### 🔧 Internal changes

- Upgrade Docker environment to use Ruby v3.3 (#7185)
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/Components/Result/text_viewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class TextViewer extends React.PureComponent {
}
}
if (currLine.textContent.length > 0) {
nodeLines.appendChild(currLine);
nodeLines.push(currLine);
}
nodeLines.push(this.raw_content.current.lastChild.cloneNode(true));
while (this.raw_content.current.firstChild) {
Expand Down
17 changes: 14 additions & 3 deletions app/assets/javascripts/Components/__tests__/text_viewer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ import {TextViewer} from "../Result/text_viewer";
describe("TextViewer", () => {
let props;

beforeEach(() => {
afterEach(cleanup);

it("should render its text content when the content ends with a new line", () => {
props = {
content: "def f(n: int) -> int:\n return n + 1\n",
annotations: [],
Expand All @@ -14,11 +16,20 @@ describe("TextViewer", () => {
};

render(<TextViewer {...props} />);

expect(screen.getByText("def f(n: int) -> int:")).toBeInTheDocument();
});

afterEach(cleanup);
it("should render its text content when the content doesn't end with a new line", () => {
props = {
content: "def f(n: int) -> int:\n return n + 1",
annotations: [],
focusLine: null,
submission_file_id: 1,
};

render(<TextViewer {...props} />);

it("should render its text content", () => {
expect(screen.getByText("def f(n: int) -> int:")).toBeInTheDocument();
});
});

0 comments on commit a620c5b

Please sign in to comment.