Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

223
Vistas
How to get selected text using javascript on vscode.dev website?

Short summary: getSelection().toString() behaves unexpectedly on https://vscode.dev.

Detailed question:

I need to write a javascript script which gets the text selected by the user. Usually I do it with getSelection().toString(), but for some reason this does not work for https://vscode.dev (online version of VSCode editor). Instead of copying all the selected text, the code above evaluates to a shortened version of the selected text, with an ellipsis in the middle. For example, if I select this text...

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30

then getSelection().toString() evaluates to

'1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n…21\n22\n23\n24\n25\n26\n27\n28\n29\n30'

that is it looses some text in the middle.

enter image description here

How to work around it and get all the selected text?

P.S. In case you ask, the Chrome console did not shorten this text, it was shortened by javascript for real: enter image description here

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda