Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
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
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();
});
});