This is an automated email from the ASF dual-hosted git repository. pabloem pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/beam.git
The following commit(s) were added to refs/heads/master by this push: new 0467235 [BEAM-13446]: fix incorrect tab symbol new 395533e Merge pull request #16212 from [BEAM-13446] [Bugfix] [Playground] fix incorrect tab symbol on the code editor 0467235 is described below commit 0467235b557e9518b447c05327b8718c981ab631 Author: Aydar Farrakhov <stranni...@gmail.com> AuthorDate: Mon Dec 13 18:08:13 2021 +0300 [BEAM-13446]: fix incorrect tab symbol --- .../code_client/grpc_code_client.dart | 15 ++++++++----- .../example_client/grpc_example_client.dart | 7 ++++-- .../lib/utils/replace_incorrect_symbols.dart | 26 ++++++++++++++++++++++ 3 files changed, 41 insertions(+), 7 deletions(-) diff --git a/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart b/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart index 2d10e82..12af093 100644 --- a/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart +++ b/playground/frontend/lib/modules/editor/repository/code_repository/code_client/grpc_code_client.dart @@ -29,6 +29,7 @@ import 'package:playground/modules/editor/repository/code_repository/run_code_er import 'package:playground/modules/editor/repository/code_repository/run_code_request.dart'; import 'package:playground/modules/editor/repository/code_repository/run_code_result.dart'; import 'package:playground/modules/sdk/models/sdk.dart'; +import 'package:playground/utils/replace_incorrect_symbols.dart'; const kGeneralError = 'Failed to execute code'; @@ -72,7 +73,7 @@ class GrpcCodeClient implements CodeClient { .getCompileOutput( grpc.GetCompileOutputRequest(pipelineUuid: pipelineUuid), ) - .then((response) => OutputResponse(response.output))); + .then((response) => _toOutputResponse(response.output))); } @override @@ -82,7 +83,7 @@ class GrpcCodeClient implements CodeClient { ) { return _runSafely(() => createClient(request.sdk) .getRunOutput(grpc.GetRunOutputRequest(pipelineUuid: pipelineUuid)) - .then((response) => OutputResponse(response.output))); + .then((response) => _toOutputResponse(response.output))); } @override @@ -92,8 +93,8 @@ class GrpcCodeClient implements CodeClient { ) { return _runSafely(() => createClient(request.sdk) .getLogs(grpc.GetLogsRequest(pipelineUuid: pipelineUuid)) - .then((response) => OutputResponse(response.output)) - .catchError((err) => OutputResponse(''))); + .then((response) => _toOutputResponse(response.output)) + .catchError((err) => _toOutputResponse(''))); } @override @@ -103,7 +104,7 @@ class GrpcCodeClient implements CodeClient { ) { return _runSafely(() => createClient(request.sdk) .getRunError(grpc.GetRunErrorRequest(pipelineUuid: pipelineUuid)) - .then((response) => OutputResponse(response.output))); + .then((response) => _toOutputResponse(response.output))); } Future<T> _runSafely<T>(Future<T> Function() invoke) async { @@ -163,4 +164,8 @@ class GrpcCodeClient implements CodeClient { } return RunCodeStatus.unspecified; } + + OutputResponse _toOutputResponse(String response) { + return OutputResponse(replaceIncorrectSymbols(response)); + } } diff --git a/playground/frontend/lib/modules/examples/repositories/example_client/grpc_example_client.dart b/playground/frontend/lib/modules/examples/repositories/example_client/grpc_example_client.dart index 88952fa..7347f3e 100644 --- a/playground/frontend/lib/modules/examples/repositories/example_client/grpc_example_client.dart +++ b/playground/frontend/lib/modules/examples/repositories/example_client/grpc_example_client.dart @@ -28,6 +28,7 @@ import 'package:playground/modules/examples/repositories/models/get_example_resp import 'package:playground/modules/examples/repositories/models/get_list_of_examples_request.dart'; import 'package:playground/modules/examples/repositories/models/get_list_of_examples_response.dart'; import 'package:playground/modules/sdk/models/sdk.dart'; +import 'package:playground/utils/replace_incorrect_symbols.dart'; class GrpcExampleClient implements ExampleClient { grpc.PlaygroundServiceClient createClient(SDK? sdk) { @@ -59,7 +60,8 @@ class GrpcExampleClient implements ExampleClient { return _runSafely( () => createClient(request.sdk) .getPrecompiledObjectCode(_getExampleRequestToGrpcRequest(request)) - .then((response) => GetExampleResponse(response.code)), + .then((response) => + GetExampleResponse(replaceIncorrectSymbols(response.code))), ); } @@ -68,7 +70,8 @@ class GrpcExampleClient implements ExampleClient { return _runSafely( () => createClient(request.sdk) .getPrecompiledObjectOutput(_getExampleRequestToGrpcRequest(request)) - .then((response) => OutputResponse(response.output)), + .then((response) => + OutputResponse(replaceIncorrectSymbols(response.output))), ); } diff --git a/playground/frontend/lib/utils/replace_incorrect_symbols.dart b/playground/frontend/lib/utils/replace_incorrect_symbols.dart new file mode 100644 index 0000000..08d75ee --- /dev/null +++ b/playground/frontend/lib/utils/replace_incorrect_symbols.dart @@ -0,0 +1,26 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const kIncorrectTabSymbol = ' '; +const kTabSymbolReplacement = ' '; + +/// sometimes code contains incorrect symbols (like tab which doesn't look properly), +/// replace it with correct ones +String replaceIncorrectSymbols(String output) { + return output.replaceAll(kIncorrectTabSymbol, kTabSymbolReplacement); +}