Skip to content

Code is deleted when formatting if statement with comments #278

Description

@brady444

Formatted code from old formatter:

extends Control


func _gui_input(event: InputEvent) -> void:
	if event is InputEventKey:
		if (
				# Stop propagation of the ` key since it's used to open/close the console
				event.keycode == KEY_QUOTELEFT
				# Stop propagation of the escape key since we don't want to unfocus the input
				|| event.keycode == KEY_ESCAPE
				# Stop propagation of the up/down keys since they're used to navigate the command history
				|| event.keycode == KEY_UP
				|| event.keycode == KEY_DOWN
				# Stop propagation of the left, right, home, end, page up, and page down keys so that we can handle caret navigation ourselves
				|| event.keycode == KEY_LEFT
				|| event.keycode == KEY_RIGHT
				|| event.keycode == KEY_HOME
				|| event.keycode == KEY_END
				|| event.keycode == KEY_PAGEUP
				|| event.keycode == KEY_PAGEDOWN
				# Stop propagation of the tab key so we can use it for autocomplete
				|| event.keycode == KEY_TAB
		):
			accept_event()

The new formatter removes some of the lines and modifies the comments:

extends Control


func _gui_input(event: InputEvent) -> void:
	if event is InputEventKey:
		if (
			# Stop propagation of the ` key since it's used to open/close the console
			event.keycode == KEY_QUOTELEFT
			# Stop propagation of the escape key since we don't want to unfocus the input ||
			# Stop propagation of the up/down keys since they're used to navigate the command history ||
			|| event.keycode == KEY_DOWN
			# Stop propagation of the left, right, home, end, page up, and page down keys so that we can handle caret navigation ourselves ||
			|| event.keycode == KEY_RIGHT || event.keycode == KEY_HOME || event.keycode == KEY_END
			|| event.keycode == KEY_PAGEUP || event.keycode == KEY_PAGEDOWN
			# Stop propagation of the tab key so we can use it for autocomplete ||
		):
			accept_event()

Without the comments, none of the lines are deleted. So I assume it's some kind of issue with parsing the comments. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions