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

Sanitize whitespace by os #255

Merged
merged 3 commits into from
Jun 26, 2024
Merged

Sanitize whitespace by os #255

merged 3 commits into from
Jun 26, 2024

Conversation

ivojawer
Copy link
Contributor

En Windows los source maps se estaban formando mal, esto es porque en los sistemas operativos de bien basados en Unix el caracter de new line es el \n pero en Windows son dos caracters \r\n

Ahora el/los caracter/es a utilizar son calculados y el calculo para sanitizar los sourcemaps se basan es esto.

Copy link

codecov bot commented Jun 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.81%. Comparing base (add80ba) to head (7734167).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #255      +/-   ##
==========================================
+ Coverage   89.80%   89.81%   +0.01%     
==========================================
  Files          26       26              
  Lines        2874     2877       +3     
  Branches      505      506       +1     
==========================================
+ Hits         2581     2584       +3     
  Misses        157      157              
  Partials      136      136              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@@ -103,6 +103,8 @@ const comment = (position: 'start' | 'end' | 'inner') => lazy('comment', () => r
const sameLineComment: Parser<Annotation> = comment('end')

export const sanitizeWhitespaces = (originalFrom: SourceIndex, originalTo: SourceIndex, input: string): [SourceIndex, SourceIndex] => {
const EOL = input.includes('\r\n') ? '\r\n' : '\n'
Copy link
Contributor Author

@ivojawer ivojawer Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aca tenia varias opciones para conseguir el valor de EOL

  1. Se podria sacar del objeto os que provee Node, pero no me parecia correcto porque no sabemos con certeza si el string que llega fue generado en el mismo SO que esta corriendo wollok-ts.
    • Aca fallaban los tests en Windows porque los strings de js van siempre con \n me parece, pero se podria mockear supongo.
  2. Calcular una vez para todos los archivos que se quieran parsear, pero tambien me hacia ruido y ademas no se que tanto mas performante seria.

Termine dejandolo asi pero no estoy seguro.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo creo que por ahora es una solución good enough para salir. Por la performance no me preocuparía mucho, no veo que vaya a afectar.

👍🏼

@ivojawer ivojawer marked this pull request as ready for review June 24, 2024 01:18
Copy link
Contributor

@fdodino fdodino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

nos vemos en agosto!!!

@@ -103,6 +103,8 @@ const comment = (position: 'start' | 'end' | 'inner') => lazy('comment', () => r
const sameLineComment: Parser<Annotation> = comment('end')

export const sanitizeWhitespaces = (originalFrom: SourceIndex, originalTo: SourceIndex, input: string): [SourceIndex, SourceIndex] => {
const EOL = input.includes('\r\n') ? '\r\n' : '\n'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yo creo que por ahora es una solución good enough para salir. Por la performance no me preocuparía mucho, no veo que vaya a afectar.

👍🏼

Copy link
Contributor

@PalumboN PalumboN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Grosssoooo!!! 🪟 🚫 👍

Yo diría de correr el CI en Windows... no sé si agarraba este error pero para estar más seguros (?

@PalumboN PalumboN merged commit 5a06cbc into master Jun 26, 2024
4 checks passed
@PalumboN PalumboN deleted the sanitize-whitespace-by-os branch June 26, 2024 21:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants