Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

222
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda