Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

220
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!